Could one tag have more than one class?

Great answer! Thanks so much rochow. I’m still learning PHP, but will digest this bit by bit. The name option looks closest to the CSs option, but on first inspection, looks even simpler. Well done!

whats the differenence between these two ?

ul.nobullet {…}

.nobullet ul {…}

Im confused

first selects all unordered lists with a class name equal to nobullet. The second selects all unordered lists that are a descendant of any element with a class name nobullet.

<ul class=“nobullet”>
</ul>

<div class=“nobullet”>
<ul
</ul>
</div>

whats the differenence between these two ?

ul.nobullet {…}

.nobullet ul {…}

Im confused

ul.nobullet means that a <ul> has a class of nobullet.

Example: <ul class=“nobullet”>

.nobullet ul means that a parent element of <ul> has a class of nobullet.
Example: <div class=“nobullet”><ul>…</ul></div>

To be specific, it means that an ancestor of the <ul> has a class of nobullet. It can be the parent, a grandparent, a grand-grandparent, etc.

It’s just my way of talking, I always say parent element when I refer to an acestor.

Just thought I’d clarify things, in case someone who doesn’t talk the way you do happens to find this thread some time in the future. :stuck_out_tongue:

I’ve never used this before, and I totally forgot that I was able to do this!
Hopefully I can implement this the next time I’m coding something up!

Thanks for reminding me! :stuck_out_tongue:

I never say ancestor element because trying to remember grandparent element, etc would confuse me. I KNOW what I mean by parent element so if in the future you hear me talking like this treat it as a speaking disorder :p.

How do you refer to your own grandparents then? Mom and Dad? :lol: :rofl: :eek: :smiley: :shifty:

or… any unordered list that is a descendant of a element classed as nobullet.

so who are the parent, grandparent and great grandparent of the <ul> ? Im not kidding.

If you have this markup

<div>
<p>
<ul class="nobullet">
...
</ul>
</p>
</div>

Not very good markup, just an example.

<div> would be the grandparent of <ul>. <p> would be the parent. Understand where I am going?

I call them granny and graddy.

No, not very good markup at all. :slight_smile:

A <ul> cannot be a child of a <p>, since lists are block-level elements.

<body>
  <div>
    <ul>...</ul>
  </div>
</body>

The body element is the ancestor of all the other elements, and the parent of the div. It’s the grandparent of the ul.

The div is an ancestor and the parent of the ul. It’s also a child and a descendant of body.

The ul is a child of the div and a descendant of the div and of body. It’s a grandchild of body.

Yes, I said it wasn’t good markup but I thought of the first tags that came to mind, essentially the theory is still the same

Paragraph is a block level element so it could. I wouldn’t advise it, but it is valid.

The code written by BoltZ is not valid. The reason why it is not valid is that there is a closing paragraph tag </p>, but no open paragraph. It is not invalid because of the unordered list being inside the paragraph, as this is not actually the case.

When an unordered list tag <ul> comes after an open paragraph tag <p>, the paragraph tag is automatically closed. Therefore, an unordered list can never be the child of a paragraph.

The following code contains the code originally written by BoltZ, with comments on how the code would be read by the parser (more or less, anyway), with the document tree added.

<div><!-- A div begins here. [div] -->
  <p><!-- A paragraph begins here. [div - p] -->
    <ul><!-- An unordered list. An unordered list can't fit inside a paragraph, so the paragraph must have ended imediately prior to the unordered lidt. Also, an unordered list begins here. [div - ul] -->
    </ul><!-- The unordered list ended here. [div] -->
  </p><!-- A closing tag for a paragraph. How very odd - I can't find any records of an open paragraph. Oh well, the author probably wrote it by mistake, so I'll just ignore it. [div] -->
</div><!-- The div ended here [] -->

No, it’s not. Paragraph elements can only contain text and inline elements. The declaration in the DTD is,

<!ELEMENT P - O (&#37;inline;)*>

Where %inline; is a parameter entity reference that expands to a sequence of #PCDATA or one of the inline element types.

Unordered lists are block-level, so they cannot be children of a paragraph.

As said before it was just an example to show what ancestors of elements are. I in no way say that it is valid or that I recommend using it. How about this.

<body>
<ul>
<li>sdf</li>
</ul>
</body>

There, use that code to bash.