A Conversation for Website Developer's Forum

CSS and XHTML

Post 1

Nireena

H'lo all. Thought I'd tap your collective wisdom for this one:

I'm trying to convert my pages from HTML 4.1 to XHTML 1.0 and get them to validate according to the W3C's tool. For some reason, the validator doesn't like lists-within-a-list, even though the lists show up properly in the browser (for example, squares for the outer list and hollow circles for the inner list). Is there something I need to fix in my style sheet or in my page so that it both validates and displays correctly?

My page looks like this:

list one item one
list one item two

list two item one
list two item two

list one item three


And my style sheet looks like this:

UL
{blah;}

UL UL
{more blah;}

smiley - huh

Thanks,
smiley - star


CSS and XHTML

Post 2

Ion the Naysayer

Heh... You picked an easy one; Obscure, but easy.

Instead of:


This is a first level item

This is a second level item



use:



This is a first level item

This is a second level item




That is, every list has to be the child of a previous list item (li), not of a previous list (ul/ol).


CSS and XHTML

Post 3

HappyDude

you might find http://alistapart.com/stories/taminglists/ of use smiley - winkeye


CSS and XHTML

Post 4

Ion the Naysayer

And just for the record I think it's counter-intuitive and a little silly so I'm going to look up the reasoning behind why they made the decision that way on the W3C www-html mailing list archives and if it still doesn't make sense to me I'm going to bring it up on the list.

Anyway, if you want to see a page as an example, look at [Broken link removed by Moderator]. Heh... and you can see the comments my prof wrote on my group's assignment if you care to... smiley - winkeye


CSS and XHTML

Post 5

Ion the Naysayer

Stupid period...

That link should read:
http://society2x03.dhs.org/groupfiles/07/cqafrs.html


CSS and XHTML

Post 6

Nireena

smiley - doh

Ion: Thanks! I agree, that is counter-intuitive. I'd be very curious to find out why they chose to do it that way. The link was useful, by the way.

HappyDude: Thanks. I'll have to bookmark that link, lots of good info there.

*microwave dings*

We should get a ramen icon. The closest I can think of is smiley - tea since I cook my ramen in a big latte mug.

smiley - star


CSS and XHTML

Post 7

dElaphant (and Zeppo his dog (and Gummo, Zeppos dog)) - Left my apostrophes at the BBC

smiley - huh It makes perfect sense to me that every item in a list be a list item, even if it is another nested list. Would it make sense if everything in a list had to a list item *except* for nested lists? What would that do to the box model and the DOM?
smiley - dog


CSS and XHTML

Post 8

DoctorMO (Keeper of the Computer, Guru, Community Artist)

It the same with tables,

you can only inbed a table in a TD not TR (unless you want it to apear at the top with some horible efects in mozzila) makes sense to me too.

-- DoctorMO --


CSS and XHTML

Post 9

Nireena


I've never dealt with tables-within-tables so I didn't know that it works the same with those.

It still seems odd to me. The list is within the first list, not within a particular item, so it made sense to me to finish the item you were dealing with first before starting the second list.

Ah well. At least it looks how I want it to now.

smiley - star


CSS and XHTML

Post 10

DoctorMO (Keeper of the Computer, Guru, Community Artist)

But the list is suposed to be with in an item i.e

Meat
Fruit
Apples
Pears
Oranges
Bread

The second list in this example is Fruit

-- DoctorMO


CSS and XHTML

Post 11

Nireena


*shrug* I guess. I'll do it however it needs to be done to get it to look the way I want it to, but I still wouldn't have set it up that.

Just out of curiosity- how do they decide who gets to be on the W3C committee and make decisions like that, anyway? Are they voted in? Do they volunteer?

smiley - star


CSS and XHTML

Post 12

Ion the Naysayer

For me, having lists embedded into list items is like writing:

Heading 1
Here is the accompanying text to go with this heading

When I think of sublists, generally it makes more sense to me to treat them like:


First List

First item
Second item

Second List

First item
Second item



where the list items are headings and the lists are not part of a list item.

With regards to the box model it makes more sense the other way but the average person doesn't care about the box model.

Tables are an entirely different case because a table row is only a container. It intuitively makes sense that you can only put table data in a table data element.

Personally I don't think of a list as a container, where I do think of a table as one. I think most people think the same way, judging from the number of times this exact issue has come up on the www-validator mailing list smiley - smiley


CSS and XHTML

Post 13

dElaphant (and Zeppo his dog (and Gummo, Zeppos dog)) - Left my apostrophes at the BBC

h1 and p are not containers, which is why you can't have a inside an , not to mention that they are two different types of data and are mutually exclusive.

Of course a list is a container. You can't have a list with nothing in it. It must contain *something*.

In fact, I think it's your example that is confusing. If you think of a list as an outline, it should be a little clearer. Consider this:

I. The top level
II. Second topic of the top level
- A. Subtopic belonging to II
- B. Subtopic belonging to II
III. Third topic of the top level


CSS and XHTML

Post 14

dElaphant (and Zeppo his dog (and Gummo, Zeppos dog)) - Left my apostrophes at the BBC

If you were to move item II to another position in the list, you would want A and B to remain with it since they are subsidiary - they are *part of item II*, not the next item in the list.

So your corrected list should actually be this:


list one item one
list one item two

list two item one
list two item two

list one item three


since presumbly the second list, being indented under "list one item two" would be subsidiary to it.
smiley - dog


CSS and XHTML

Post 15

dElaphant (and Zeppo his dog (and Gummo, Zeppos dog)) - Left my apostrophes at the BBC

(sorry I had to split that, I have trouble posting messages over a certain length).
smiley - dog


CSS and XHTML

Post 16

DoctorMO (Keeper of the Computer, Guru, Community Artist)

I thought so too, I forgot about the tabs so the post ended up a bit smiley - weird, rushing does that smiley - silly so whats the general feeling? W3C are right?

I think so, being a programmer of other lanuages.

-- DoctorMO --


CSS and XHTML

Post 17

Ion the Naysayer

Naturally h1 and p don't make sense like that. That's why the lists don't make sense to me the way they are.

Why should a list container not be allowed to contain another container without having content? It makes more sense to me to put a container into a container than to put a container into the content...

Why does a list necessarily have to be an outline? They don't _have_ to be used as summaries or tables of contents.

I understand why it is the way it is but that doesn't mean that I agree that that's necessarily the best way to do it. It makes the assumption that every sublist needs to be the child of a list item which isn't always the case.

If you apply the same logic to and elements, it should follow that a heading needs to be attached to the paragraphs associated with it. Obviously this isn't the way it works and because of the way the box model relates to the and elements, doing it that way is non-sensical but do you see what I'm getting at?

Either behaviour is useful under different circumstances but I think they should have made it consistent because it's easier on the HTML author. The programmer should be going out of the way for the author, not the other way around.


CSS and XHTML

Post 18

Frankie Roberto

Incidentally, XHTML 2 does away with and marks headings up like this:


quick introduction</>
Part 1
some content


Sub-division 1



Sub-division 1


Conclusion


CSS and XHTML

Post 19

dElaphant (and Zeppo his dog (and Gummo, Zeppos dog)) - Left my apostrophes at the BBC

Really? Then putting everything in a does make it more consistent, to work more like tables and lists.

Ion, if it makes sense to you to have embedded lists the way you suggest, then the following would be legal:




An item>




But then how would that be rendered? It makes the part meaningless except for changing the type of bullet (and that can be done in better ways). The point is that the is there to contain items, just like , and having something floating around in it without delineation (the <li&gtsmiley - winkeye is pointless.

I do see what you're getting at, but I think you're looking at it backwards.
smiley - dog


CSS and XHTML

Post 20

DoctorMO (Keeper of the Computer, Guru, Community Artist)

I think if what your sujesting is that you wanted two difrent styles...


First Item
Second Item



First Item
Second Item


then...

UL.First
{
/*Style here*/
}

UL.Second
{
/*Style here*/
}

Would this not be more apropriat for none parenting nodes?

-- DoctorMO --


Key: Complain about this post

Write an Entry

"The Hitchhiker's Guide to the Galaxy is a wholly remarkable book. It has been compiled and recompiled many times and under many different editorships. It contains contributions from countless numbers of travellers and researchers."

Write an entry
Read more