# Strict XHTML and Unordered Lists

**URL:** <https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672>\
**Category:** Factual Questions\
**Created:** [May 9, 2008, 8:13am UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672 "2008-05-09T08:13:19Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Will\_Repair](https://avatars.discourse-cdn.com/v4/letter/w/a698b9/32.png) [@Will\_Repair](https://boards.straightdope.com/u/Will_Repair)\
**Post date:** [May 9, 2008, 8:13am UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/1 "2008-05-09T08:13:19Z")

</div>

Why doesn’t this[strict \<xhtml\> web page](http://willrepair.com/ComputerElectrician.com/listindex.html) pass the [W3C.org Validator](http://validator.w3.org/)?

---

<div class="post-metadata">

**Author:** ![Will\_Repair](https://avatars.discourse-cdn.com/v4/letter/w/a698b9/32.png) [@Will\_Repair](https://boards.straightdope.com/u/Will_Repair)\
**Post date:** [May 9, 2008, 8:46am UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/2 "2008-05-09T08:46:42Z")

</div>

This is the first of 11 errors.

Line 14, Column 5: document type does not allow element “ul” here; missing one of “object”, “ins”, “del”, “map”, “button” start-tag.

\<ul\>

The mentioned element is not allowed to appear in the context in which you’ve placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you’ve forgotten to close a previous element.

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [May 9, 2008, 9:46am UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/3 "2008-05-09T09:46:47Z")

</div>

I don’t know. Your example looks identical to the ‘correct’ nested list example here:  
[http://www.w3schools.com/xhtml/xhtml\_html.asp](http://www.w3schools.com/xhtml/xhtml_html.asp)

-However, I must be overlooking something obvious, as I replaced your nested lists with a C&P of the code on that page and it validated OK…

---

<div class="post-metadata">

**Author:** ![Will\_Repair](https://avatars.discourse-cdn.com/v4/letter/w/a698b9/32.png) [@Will\_Repair](https://boards.straightdope.com/u/Will_Repair)\
**Post date:** [May 9, 2008, 9:57am UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/4 "2008-05-09T09:57:32Z")

</div>

I have an ending \<ul\> instead of \</ul\>.  
Now I’ll start splicing my real index.html into [listindex.com](http://listindex.com) until I find the error.  
\<body\>  
\<p\>  
Items  
\<ul\>  
\<li\>SubItem\</li\>  
\<li\>SubItem  
\<ul\>  
\<li\>SubSubItem\</li\>  
\<li\>SubSubItem\</li\>  
\</ul\>  
\</li\>  
\<li\>SubItem\</li\>  
\<ul\>  
\</p\>  
\</body\>

---

<div class="post-metadata">

**Author:** ![Will\_Repair](https://avatars.discourse-cdn.com/v4/letter/w/a698b9/32.png) [@Will\_Repair](https://boards.straightdope.com/u/Will_Repair)\
**Post date:** [May 9, 2008, 10:07am UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/5 "2008-05-09T10:07:51Z")

</div>

Its the \<p\> tags. Without the \<ul\> instead of \</ul\> at the end of the list and without the \<p\> and \</p\> it passes.

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [May 9, 2008, 10:43am UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/6 "2008-05-09T10:43:05Z")

</div>

Do you need the \<p\> tags? Can you put it inside a \<div\> instead?

---

<div class="post-metadata">

**Author:** ![Will\_Repair](https://avatars.discourse-cdn.com/v4/letter/w/a698b9/32.png) [@Will\_Repair](https://boards.straightdope.com/u/Will_Repair)\
**Post date:** [May 9, 2008, 11:03am UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/7 "2008-05-09T11:03:30Z")

</div>

[QUOTE=Mangetout]  
Do you need the \<p\> tags? Can you put it inside a \<div\> instead?  
[/QUOTE]  
Yes but the formating is different. Within the \<p\>\</p\> the items are spaced further apart.

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [May 9, 2008, 11:10am UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/8 "2008-05-09T11:10:49Z")

</div>

[QUOTE=Will Repair]  
Yes but the formating is different. Within the \<p\>\</p\> the items are spaced further apart.  
[/QUOTE]

Could that be overcome in your CSS? - something like:

.spaciouslist {  
line-height: 140%  
}

Then:

\<div class=“spaciouslist”\>  
[your nested lists]  
\</div\>

---

<div class="post-metadata">

**Author:** ![jjimm](https://avatars.discourse-cdn.com/v4/letter/j/ba8739/32.png) [@jjimm](https://boards.straightdope.com/u/jjimm)\
**Post date:** [May 9, 2008, 1:31pm UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/9 "2008-05-09T13:31:42Z")

</div>

I believe you should close the \</li\> before opening the \<ul\>

```auto

<li>List item</li>
 <ul>
 <li>New list item</li>
 </ul>
<li>Next list item</li>

```

And, of course, lose the P tags. Use a DIV with an ID if you need to specifically address that one list, and put a line-height on the LI styling within that ID. Otherwise just don’t bother.

---

<div class="post-metadata">

**Author:** ![Mangetout](https://sea3.discourse-cdn.com/straightdope/user_avatar/boards.straightdope.com/mangetout/32/19_2.png) [@Mangetout](https://boards.straightdope.com/u/Mangetout)\
**Post date:** [May 9, 2008, 3:24pm UTC](https://boards.straightdope.com/t/strict-xhtml-and-unordered-lists/448672/10 "2008-05-09T15:24:36Z")

</div>

Actually, I’m still a bit wet behind the ears with CSS… if you want all lists to be a bit more spacious, couldn’t you just modify the way the \<li\> tag works by putting:

li {  
line-height: 140%  
}

in the CSS?
