Home arrow HTML arrow Page 4 - Designing with Nested HTML Lists
HTML

Designing with Nested HTML Lists


Nested HTML lists offer an abundance of uses; they're not just for navigation these days. If you want to learn how to get the most out of this common web site feature, keep reading; we'll explain how to use them in ways you might not have thought of yet.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 5
May 15, 2009
TABLE OF CONTENTS:
  1. · Designing with Nested HTML Lists
  2. · Using nested HTML lists
  3. · Coding multiple sub lists
  4. · Building a nested HTML list with multiple sub-levels

print this article
SEARCH DEVARTICLES

TOOLS YOU CAN USE

advertisement
Designing with Nested HTML Lists - Building a nested HTML list with multiple sub-levels
(Page 4 of 4 )

In the section that you just read, I explained how to build a nested HTML list comprised of multiple sub lists with one level of depth. Nonetheless, as you might have guessed, it's possible to expand the list's hierarchical structure and incorporate more sub-levels with minor effort.

Bearing in mind this concept, below I coded a brand new example that shows how to construct a nested list that is also "nested within another." Does that sound a bit confusing? Don't worry; the following code sample should dissipate any doubts that you might have on this topic:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />

<title>Example on building multiple nested HTML lists</title>

</head>

<body>

<h1>Example on building multiple nested HTML lists</h1>

<ul>

<li>List Item 1

<ul>

<li>Sub Item 1</li>

<li>Sub Item 2</li>

<li>Sub Item 3</li>

<li>Sub Item 4</li>

<li>Sub Item 5</li>

</ul>

</li>

<li>List Item 2

<ul>

<li>Sub Item 1

<ul>

<li>Sub Item 1</li>

<li>Sub Item 2</li>

<li>Sub Item 3</li>

<li>Sub Item 4</li>

<li>Sub Item 5</li>

</ul>

</li>

<li>Sub Item 2</li>

<li>Sub Item 3</li>

<li>Sub Item 4</li>

<li>Sub Item 5</li>

</ul>

</li>

<li>List Item 3

<ul>

<li>Sub Item 1</li>

<li>Sub Item 2</li>

<li>Sub Item 3</li>

<li>Sub Item 4</li>

<li>Sub Item 5</li>

</ul>

</li>

<li>List Item 4

<ul>

<li>Sub Item 1</li>

<li>Sub Item 2</li>

<li>Sub Item 3</li>

<li>Sub Item 4</li>

<li>Sub Item 5</li>

</ul>

</li>

</ul>

</body>

</html>


Even though at first sight the structure of the above nested HTML list seems to be quite complex, the truth is that it's fairly simple. In this specific case, an additional sub level has been incorporated into the second sub list, which expands its hierarchy even more -- but this apparently complicated process is reduced to appending as many child lists as needed. That's all.

Finally, the following screen capture should give you a more clear idea of how the nested HTML list created a few lines before is displayed on the screen:



And with this concluding hands-on example, I'm finishing this introductory chapter on building nested HTML lists. As usual, feel free to edit all of the code samples developed in this tutorial, so you can get a more solid background in creating these useful web page elements.

Final thoughts

In this first episode of the series, I walked through the basics of building nested HTML lists. As you saw before, this process is pretty straightforward and doesn't offer major difficulties, even if you're just getting started using lists within your own web sites.

In the forthcoming article, I'll be discussing how to improve the visual appearance of nested lists by using a few simple CSS styles. Thus, now that you've been warned about the topics that will be covered in the next tutorial, you don't have any excuses to miss it!


DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

blog comments powered by Disqus
HTML ARTICLES

- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5
- BBC Adopts HTML 5, Mozilla Addresses Issues
- Advanced Sticky Footers in HTML and CSS
- HTML and CSS Sticky Footers
- Strategy Analytics Predicts HTML5 Phones to ...
- HTML5 Guidelines for Web Developers
- Learning HTML5 Game Programming
- More Engaging CSS3 and HTML Background Effec...
- Engaging HTML and CSS3 Background Effects
- More Web Columns with CSS3 and HTML
- Columns with CSS3 and HTML
- Creating Inline-Block HTML Elements with CSS
- Drag and Drop in HTML5: Parsing Local Files

Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 



© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 6 - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials