Nesting Lists in HTML


Nested lists are lists that appear inside other lists. In HTML markup, a nested list takes the place of a list item, like so:

 <ol>   <li>First item of the main list</li>   <li>Second item of the main list</li>   <li>Third item of the main list</li> <!-- Here comes the nested list -->   <ol>     <li>First item of the nested list</li>     <li>Second item of the nested list</li>     <li>Third item of the nested list</li>   </ol> <!-- There went the nested list -->   <li>Fourth item of the main list</li>   <li>Fifth item of the main list</li> </ol> 

You may nest list within lists within lists if you so choose:

 <ul>   <li>First item of the main list</li>   <li>Second item of the main list</li>   <li>Third item of the main list</li> <!-- Here comes the nested list -->   <ul>     <li>First item of the nested list</li>     <li>Second item of the nested list</li> <!-- Here comes a nested list within the nested list -->     <ul>       <li>First item of the very nested list</li>       <li>Second item of the very nested list</li>     </ul> <!-- There went the nested list within the nested list -->     <li>Third item of the nested list</li>   </ul> <!-- There went the nested list -->   <li>Fourth item of the main list</li>   <li>Fifth item of the main list</li> </ul> 

GEEKSPEAK

Nested lists are lists that appear inside other lists.


When you nest unordered lists, the browser typically cycles through the bullet types for each successive nested list. So, if you start the list with a disc (filled) bullet, a nested list gets the circle (hollow) bullet, a nested list within the nested list gets the square bullet, and a nested list within the nested list within the nested list gets the disc again, and so on, as Figure 52.2 shows.

Figure 52.2. The browser typically cycles through the bullet types for each successive nested list in an unordered list.


TIP

You don't get the same treatment with ordered lists. To create an outline effect with an ordered list, you must explicitly set the type attribute for each nested listor whip up a style sheet. See the Toolkit at the end of this topic for details.




Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net