Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Chapter 6: HTML5 - Lists & Content Organization

Learning Objectives

By the end of this chapter, you will be able to:

  • Use unordered lists for non-sequential information
  • Use ordered lists for sequential or numbered information
  • Create description lists for term-definition pairs
  • Build nested lists for hierarchical content
  • Use semantic list markup for navigation menus
  • Organize content effectively with lists

Concept Introduction: Lists

Lists organize content in a structured way. HTML has three types of lists:

  • Unordered lists - Items without specific order (bullets)
  • Ordered lists - Numbered items in sequence
  • Description lists - Terms with definitions

Lists make content scannable, accessible, and easier to understand.

Learn more: W3Schools HTML Lists

Unordered Lists

Unordered lists use the <ul> tag with <li> (list item) elements:

<ul>
  <li>First item</li>
  <li>Second item</li>
  <li>Third item</li>
</ul>

This displays as bullet points:

  • First item
  • Second item
  • Third item

Learn more: W3Schools Unordered Lists

Ordered Lists

Ordered lists use the <ol> tag with <li> elements:

<ol>
  <li>First step</li>
  <li>Second step</li>
  <li>Third step</li>
</ol>

This displays as numbered items:

  1. First step
  2. Second step
  3. Third step

Learn more: W3Schools Ordered Lists

Description Lists

Description lists pair terms with definitions using <dl>, <dt> (term), and <dd> (definition):

<dl>
  <dt>HTML</dt>
  <dd>HyperText Markup Language - the standard markup 
      language for creating web pages.</dd>
  
  <dt>CSS</dt>
  <dd>Cascading Style Sheets - used to style HTML elements
      and control layout and presentation.</dd>
  
  <dt>JavaScript</dt>
  <dd>A programming language that adds interactivity and 
      dynamic behavior to web pages.</dd>
</dl>

Learn more: W3Schools Description Lists

Nested Lists

Lists can contain other lists for hierarchical information:

<ul>
  <li>Fruits
    <ul>
      <li>Apples</li>
      <li>Oranges</li>
      <li>Bananas</li>
    </ul>
  </li>
  <li>Vegetables
    <ul>
      <li>Carrots</li>
      <li>Broccoli</li>
      <li>Spinach</li>
    </ul>
  </li>
</ul>

Learn more: W3Schools Nested Lists

List Attributes

Unordered List Styles

<!-- Disc (default) -->
<ul style="list-style-type: disc;">
  <li>Item 1</li>
</ul>

<!-- Circle -->
<ul style="list-style-type: circle;">
  <li>Item 1</li>
</ul>

<!-- Square -->
<ul style="list-style-type: square;">
  <li>Item 1</li>
</ul>

<!-- None (no bullets) -->
<ul style="list-style-type: none;">
  <li>Item 1</li>
</ul>

Ordered List Styles

<!-- 1, 2, 3 (default) -->
<ol style="list-style-type: decimal;">
  <li>First</li>
</ol>

<!-- a, b, c (lowercase) -->
<ol style="list-style-type: lower-alpha;">
  <li>First</li>
</ol>

<!-- A, B, C (uppercase) -->
<ol style="list-style-type: upper-alpha;">
  <li>First</li>
</ol>

<!-- i, ii, iii (roman numerals) -->
<ol style="list-style-type: lower-roman;">
  <li>First</li>
</ol>

Learn more: W3Schools List Style Types

Step-by-Step Exercise: Create a Product Catalog

Step 1: Create catalog.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1">
    <title>Product Catalog</title>
  </head>
  <body>
    <h1>Online Product Catalog</h1>
    
    <h2>Our Products</h2>
    
    <ul>
      <li>Electronics
        <ul>
          <li>Laptops
            <ul>
              <li>Gaming Laptops</li>
              <li>Business Laptops</li>
              <li>Ultrabooks</li>
            </ul>
          </li>
          <li>Smartphones</li>
          <li>Tablets</li>
        </ul>
      </li>
      <li>Home & Kitchen
        <ul>
          <li>Kitchen Appliances</li>
          <li>Furniture</li>
          <li>Decor</li>
        </ul>
      </li>
      <li>Fashion
        <ul>
          <li>Men's Clothing</li>
          <li>Women's Clothing</li>
          <li>Shoes</li>
        </ul>
      </li>
    </ul>
    
  </body>
</html>

Step 2: Create course-syllabus.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1">
    <title>Course Syllabus</title>
  </head>
  <body>
    <h1>Web Design Course Syllabus</h1>
    
    <h2>Course Overview</h2>
    <p>Learn the fundamentals of web design and development
       through practical hands-on exercises.</p>
    
    <h2>Course Topics</h2>
    <ol>
      <li>Introduction to Web & HTML Basics</li>
      <li>HTML5 - Headings, Paragraphs & Text Formatting</li>
      <li>HTML5 - Images, Links & Media</li>
      <li>HTML5 - Tables & Structured Data</li>
      <li>HTML5 - Forms & User Input</li>
      <li>HTML5 - Lists & Content Organization</li>
      <li>CSS Basics - Selectors, Colors & Backgrounds</li>
      <li>CSS Intermediate - Box Model & Typography</li>
      <li>CSS Advanced - Effects & Animation</li>
      <li>JavaScript Basics - Interactivity & Functionality</li>
    </ol>
    
    <h2>Course Requirements</h2>
    <ul>
      <li>Complete all 10 practical exercises</li>
      <li>Create a final portfolio project</li>
      <li>Participate in weekly code reviews</li>
      <li>Pass the web design assessment</li>
    </ul>
    
    <h2>Grading Breakdown</h2>
    <dl>
      <dt>Participation</dt>
      <dd>10% - Active engagement in class and discussions</dd>
      
      <dt>Assignments</dt>
      <dd>30% - Weekly practical exercises and coding tasks</dd>
      
      <dt>Project Work</dt>
      <dd>40% - Final portfolio project demonstrating all skills</dd>
      
      <dt>Assessment</dt>
      <dd>20% - Final web design technical assessment</dd>
    </dl>
    
  </body>
</html>

Step-by-Step Exercise: Create a Navigation Menu

Step 1: Create navigation-menu.html

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1">
    <title>Website Navigation</title>
  </head>
  <body>
    <h1>My Website</h1>
    
    <nav>
      <ul style="list-style-type: none;">
        <li><a href="/">Home</a></li>
        <li>
          Products
          <ul style="list-style-type: none;">
            <li><a href="/products/electronics">Electronics</a></li>
            <li><a href="/products/books">Books</a></li>
            <li><a href="/products/clothing">Clothing</a></li>
          </ul>
        </li>
        <li>
          Services
          <ul style="list-style-type: none;">
            <li><a href="/services/consulting">Consulting</a></li>
            <li><a href="/services/support">Support</a></li>
            <li><a href="/services/training">Training</a></li>
          </ul>
        </li>
        <li><a href="/about">About Us</a></li>
        <li><a href="/contact">Contact</a></li>
      </ul>
    </nav>
    
    <h2>Welcome</h2>
    <p>Use the navigation menu above to explore our website.
    </p>
    
  </body>
</html>

Step-by-Step Exercise: Create a Recipe Instructions List

<!DOCTYPE html>
<html>
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width, initial-scale=1">
    <title>Recipe</title>
  </head>
  <body>
    <h1>Chocolate Chip Cookies Recipe</h1>
    
    <h2>Ingredients</h2>
    <ul>
      <li>2 1/4 cups flour</li>
      <li>1 tsp baking soda</li>
      <li>1 tsp salt</li>
      <li>1 cup butter, softened</li>
      <li>3/4 cup sugar</li>
      <li>3/4 cup brown sugar</li>
      <li>2 eggs</li>
      <li>2 tsp vanilla extract</li>
      <li>2 cups chocolate chips</li>
    </ul>
    
    <h2>Instructions</h2>
    <ol>
      <li>Preheat oven to 375°F (190°C)</li>
      <li>In a small bowl, combine flour, baking soda, 
          and salt</li>
      <li>In a large bowl, beat butter and sugars until 
          creamy</li>
      <li>Add eggs and vanilla extract to butter mixture</li>
      <li>Gradually beat in flour mixture</li>
      <li>Stir in chocolate chips</li>
      <li>Drop rounded tablespoons onto ungreased baking sheets</li>
      <li>Bake 9-11 minutes or until light brown</li>
      <li>Cool on baking sheets for 2 minutes</li>
      <li>Transfer to wire racks to cool completely</li>
    </ol>
    
    <h2>Tips</h2>
    <ul>
      <li>Don't overbake - cookies should be slightly soft 
          in the center</li>
      <li>Use room temperature ingredients for best results</li>
      <li>Mix in nuts (walnuts, pecans) for extra flavor</li>
    </ul>
    
  </body>
</html>

Best Practices for Lists

✅ Do’s

  • Use <ul> for unordered information
  • Use <ol> for sequential or ranked information
  • Use <li> for each list item
  • Use <dl>, <dt>, <dd> for term-definition pairs
  • Use semantic <nav> with <ul> for navigation
  • Use nested lists for hierarchical information
  • Keep list items concise and parallel in structure

❌ Don’ts

  • Don’t use lists for layout or spacing
  • Don’t mix ordered and unordered lists unnecessarily
  • Don’t create overly deep nesting (3+ levels is hard to follow)
  • Don’t leave <li> tags unclosed
  • Don’t use lists for content that isn’t list-like
  • Don’t forget to use meaningful list content

Common List Uses

Use CaseList TypeExample
Bullet points, featuresUnordered <ul>Product features, benefits
Steps, instructions, rankingOrdered <ol>Recipes, rankings, tutorials
Glossary, definitionsDescription <dl>Terms and definitions
Navigation menuUnordered <ul> with semantic <nav>Site navigation
Categories with subcategoriesNested listProduct catalog
Pros and consUnordered <ul>Comparison lists

Accessibility in Lists

<!-- Good: Semantic navigation with list -->
<nav>
  <ul>
    <li><a href="/">Home</a></li>
    <li><a href="/about">About</a></li>
  </ul>
</nav>

<!-- Good: Using description lists -->
<dl>
  <dt>Term</dt>
  <dd>Definition</dd>
</dl>

<!-- Good: Nested lists for hierarchy -->
<ul>
  <li>Category
    <ul>
      <li>Subcategory</li>
    </ul>
  </li>
</ul>

Screen readers and assistive technologies handle lists well when they’re properly structured and semantic.

List Styling Examples

Changing Bullet Styles

<!-- Remove bullets for navigation -->
<ul style="list-style-type: none;">
  <li><a href="/">Link</a></li>
</ul>

<!-- Use squares instead of circles -->
<ul style="list-style-type: square;">
  <li>Item</li>
</ul>

Changing Number Styles

<!-- Roman numerals -->
<ol style="list-style-type: upper-roman;">
  <li>First</li>
</ol>

<!-- Lowercase letters -->
<ol style="list-style-type: lower-alpha;">
  <li>First</li>
</ol>

Challenge Exercise (Optional)

Create a comprehensive content organization page with:

  1. Main navigation menu using semantic <nav> and <ul>
  2. Product categories using nested unordered lists
  3. Numbered steps or instructions using ordered list
  4. Glossary section using description list <dl>
  5. Features list using unordered list
  6. FAQ section organized with description lists or headings
  7. At least one nested list with 3 levels
  8. Use different list-style-type values for variety
  9. Include at least 20 list items across all lists
  10. Test navigation links and verify structure is semantic

Key Takeaways

  • <ul> for unordered bullet lists
  • <ol> for ordered numbered lists
  • <li> for each list item in both
  • <dl>, <dt>, <dd> for term-definition pairs
  • Nested lists show hierarchical relationships
  • Use semantic <nav> with <ul> for navigation
  • Remove bullets with list-style-type: none; for navigation
  • Lists improve accessibility and scannability
  • Keep list items parallel and concise
  • Test navigation and links in your lists

References