Home arrow HTML arrow Page 2 - Styling Elements of Nested HTML Lists
HTML

Styling Elements of Nested HTML Lists


Welcome to the second part of a three-part series on designing with nested HTML lists. This series shows you how to nest HTML lists by using a hands-on approach, and demonstrates how to use them for building standards-compliant drop-down menus.

Author Info:
By: Alejandro Gervasio
Rating: 5 stars5 stars5 stars5 stars5 stars / 1
May 22, 2009
TABLE OF CONTENTS:
  1. · Styling Elements of Nested HTML Lists
  2. · Review: building basic nested HTML lists
  3. · Polish the look of nested HTML lists with CSS styles
  4. · Building a hierarchical navigational system

print this article
SEARCH DEVARTICLES

Styling Elements of Nested HTML Lists - Review: building basic nested HTML lists
(Page 2 of 4 )

If you still havenít read the preceding article of this series, where I introduced the core concepts for nesting HTML lists, in the next few lines I included the complete source code for a couple of hands-on examples developed in the tutorial. The examples demonstrated how to create these web page elements using different levels of nesting.

Here are the corresponding code samples:

(example on building a one-level deep nested list)

<!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</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>

<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 5

<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 6

<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 7

<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 8

<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 9

<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 10

<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>


(example on building a two-level deep nested list)

<!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>


If you pay close attention to the above code samples, then youíll realize how simple it is to build nested HTML lists. As you can see, the first case shows the creation of a list that has one level of nesting, while the second example is a bit more complex; it illustrates how to construct a two-level-deep nested list. That was pretty easy to code and follow.

Now that you have surely grasped the logic that drives creating a few simple nested HTML lists, itís time to enhance their visual appearance. As I expressed in the introduction, the examples developed so far look pretty skeletal, meaning that itís necessary to incorporate into them some CSS styles, so they can look a bit more professional.

Thus, in the upcoming segment Iíll be showing you how to improve via CSS the visual presentation of the nested HTML lists that you learned before. However, to learn the details of how this process will be accomplished, please visit the following section. Itís only one click away.


blog comments powered by Disqus
HTML ARTICLES

- Does HTML5 Need a Main Element?
- Revisiting the HTML5 vs. Native Debate
- HTML5: Not for Phone Apps?
- HTML5 or Native?
- Job Hunting? Freelancer.com Lists This Quart...
- HTML5 in the News
- Report: HTML5 Mobile Performance Lags
- The Top HTML5 Audio Players
- Top HTML5 Video Tutorials
- HTML5: Reasons to Learn and Use It
- More of the Top Tutorials for HTML5 Forms
- MobileAppWizard Releases HTML5 App Builder
- HTML5 Boilerplate: Working with jQuery and M...
- HTML5 Boilerplate Introduction
- New API Platform for HTML5

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




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