Is it possible to write W3C compliant multi-level bullet points (unordered list) in HTML?
Nested ul can be used, but is not W3C compliant.
<ul> <li>myItem 1</li> <li>myItem 2</li> <ul> <li>myItem 2a</li> </ul> <li>myItem 3</li> <li>myItem 4</li> </ul>
In Visual Studio, the above code gives the warning: Validation (XHTML 1.0 Transitional): Element 'ul' cannot be nested within element 'ul'
Before trying the following steps, realize that to create a multilevel list in HTML you must nest the list into another list item. Also, because HTML only has either a bullet list or number list, if you want to change the type of list, you must use CSS to create a new style type.
You create an unordered list using the ul tag. Then, you use the li tag to list each and every one of the items you want your list to include. tag.
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The only valid child of either a ul
or ol
is an li
element; an li
can, however, contain a ul
(or ol
). To achieve your aim:
<ul> <li>myItem 1</li> <li>myItem 2</li> <li style="list-style-type:none"> <ul> <li>myItem 2a</li> </ul> </li> <li>myItem 3</li> <li>myItem 4</li> </ul>
Complementing David Thomas answer, this would remove the unwanted bullet:
<ul> <li>myItem 1</li> <li>myItem 2 <ul> <li>myItem 2a</li> </ul> </li> <li>myItem 3</li> <li>myItem 4</li> </ul>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With