Forum Moderators: open

Message Too Old, No Replies

ul without li inside invalid

is this correct?

         

HelenDev

10:13 am on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just a quick one,

I know that a list item which isn't in a list is invalid, but is a <ul> which doesn't contain any <li>s also invalid?

Our CMS is generating an empty <ul></ul> and I think it's invalidating the HTML, just want to check before I start to fix...

Thanks.

tedster

12:43 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, an empty list is not valid, even in the chaos that was HTML 3.2 --

UL unordered lists
These require start and end tags, and contain one or
more LI elements representing individual list items.

[w3.org...]

The error message I get from the W3C validator says: end tag for "UL" which is not finished

HelenDev

12:58 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Cheers tedster :)

That's what I suspected, just couldn't see it in the HTML 4.01 spec.

tedster

2:24 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Neither could I ;) -- that's why I resorted to HTML 3.2

Along a similar line, I was reading the W3C rendering instructions for user agents recently, and noted that an empty paragraph element <p></p> is not supposed to be rendered in any way. However it does pass the validator for html 4.01 -- event strict!

Hester

3:06 pm on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



UL unordered lists
These require start and end tags, and contain one or
more
LI elements representing individual list items.

Sounds to me like it has to have a LI element as well inside it according to the above.