Menu

Log in

Sign up

From beginner to master of web design, coding, infrastructure operation, business development and marketing

  • COURSES
  • HTML & CSS Introduction
  • HTML & CSS Coding with AI
  • Linux Introduction
  • Docker Basics
  • Git & GitHub Introduction
  • JavaScript Coding with AI
  • Django Introduction
  • AWS Basics
  • Figma Introduction
  • SEO Tutorial for Beginners
  • SEO with AI
  • OTHERS
  • About
  • Terms of Service
  • Privacy Policy

© 2024 D-Libro. All Rights Reserved

HTML & CSS IntroductionChapter 5. HTML: Create Lists and Tables

Create Lists

Create Lists

How to Create Lists in HTML

In this section, we'll explain how to create lists. In HTML, there are two types of lists – unordered lists and ordered lists. An unordered list is a list with bullets without any particular order. An ordered list is a list with numbers.

<ul>, <ol> and <li>

There are three key tags used in HTML to structure lists.

<ul>

Called unordered list tag. Used to group list items with bullets.

<ol>

Called ordered list tag. Used to group list items with numbers.

<li>

Called list tag. Used to list up items nested under the <ul> or <ol> tag.

Unordered List

This is an example of an unordered list, which we have already shown in Chapter 3.

HTML Example 1 – unordered list (ul)
<h2>Salad</h2>
<ul>
  <li>Greek Salad</li>
  <li>Avocado Salad</li>
  <li>Tomato Salad</li>
</ul>
<h2>Soup</h2>
<ul>
  <li>Minestrone</li>
  <li>Clam Chowder</li>
  <li>Corn Soup</li>
</ul>

The HTML code above is displayed in the browser as shown below.

Web Browser
Unordered list

The type attribute

You can change the marker type of list items with this attribute. When you don't want to show the marker, you can use type="none". When you want to change the marker to a square shape, use type="square".

Here are the examples.

HTML Example 2 – ul with type="none"
<ul type="none">
  <li>Greek Salad</li>
  <li>Avocado Salad</li>
  <li>Tomato Salad</li>
</ul>

The HTML code above is displayed in the browser as shown below.

Web Browser
Unordered list with type = none
HTML Example 3 – ul with type="square"
<ul type="square">
  <li>Minestrone</li>
  <li>Clam Chowder</li>
  <li>Corn Soup</li>
</ul>

The HTML code above is displayed in the browser as shown below.

Web Browser
Unordered list with type =square

Ordered List

For ordered list, there are two frequently used attributes – start and type.

The start attribute

You can change the start number of the first list item with this attribute. For example, if you want to start from 4 instead of 1, you can use this attribute.

HTML Example 4 – ol with the start attribute
<ol>
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>

<p>Count Again</p>

<ol start="4">
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>

The HTML code above is displayed in the browser as shown below.

Web Browser
Ordered list with the start attribute

The type attribute

You can change the marker type of list items with this attribute. For example:

  • type="a": a, b, c, d, e, ...
  • type="A": A, B, C, D, E,...
  • type="i": i, ii, iii, iv, v, ...
HTML Example 5 – ol with the type attribute
<ol type="a">
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>
<ol type="A">
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>
<ol type="i">
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>

The HTML code above is displayed in the browser as shown below.

Web Browser
Ordered list with the type attribute

­

Nested List

Nesting a list means placing a list inside of another list like in the illustration below.

Nested list

What you need to do for nesting a list is place the <ul> or <ol> element within another <ul> or <ol> element as shown below.

<ol>
  <li>item</li>
  <li>item</li>
  <ul>
    <li>item</li>
    <li>item</li>
  </ul>
  <li>item</li>
  <li>item</li>
</ol>

Practice

Objective:
Create customized lists in HTML

1. Create a new HTML file for this chapter

  • Using VS Code, create a new file chapter5.html under the html-css-introduction directory.
  • Type ! and hit the tab or enter the key to create the HTML template.
  • Change the <title> section to 5. HTML: Create Lists and Tables.

2. Create unordered lists with different type attributes

In the <body> section, type (copy & paste) the following code. And save the file (⌘ + S for Mac, Ctrl + S for Windows).

chapter5.html
<h1>Chapter 5. HTML: Create Lists and Tables</h1>
<h2>Lists</h2>

<h3>1. Unordered Lists</h3>

<ul type="none">
  <li>Greek Salad</li>
  <li>Avocado Salad</li>
  <li>Tomato Salad</li>
</ul>

<ul type="square">
  <li>Minestrone</li>
  <li>Clam Chowder</li>
  <li>Corn Soup</li>
</ul>

<h3>2. Ordered Lists: Count Again</h3>
<ol>
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>

<p>Count Again</p>

<ol start="4">
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>

<h3>3. Ordered Lists: Various Markers</h3>
<ol type="a">
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>
<ol type="A">
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>
<ol type="i">
  <li>item</li>
  <li>item</li>
  <li>item</li>
</ol>

<h3>4. Nested Lists</h3>
<ol>
  <li>item</li>
  <li>item</li>
  <ul>
    <li>item</li>
    <li>item</li>
  </ul>
  <li>item</li>
  <li>item</li>
</ol>

<hr>

2. Check the result with a browser

Open the chapter5.html file with a browser. You should be able to see various types of lists in a browser, like the ones in the main section of this lesson, with titles for each list.

You can also check the sample result here (Demo Site).

link

Idea<hr> Horizontal Rule

The <hr> tag is used to add a thematic break (changing a topic) in the HTML document. Visually, it likely shows a horizontal line in the browser. The reason why we say "likely" is that these days the role of the <hr> tag is mainly providing semantics. The style of the <hr> element can differ by browser. If you want to add a horizontal line for design purposes, you should use CSS.


You can also learn this topic offline. Click AmazonKindle.

More Topics to Explore

Box-Shadow vs. Drop-Shadow: How They Are Different?

Box-Shadow vs. Drop-Shadow: How They Are Different?

Attribute Selector in CSS

Attribute Selector in CSS

Managing Flex Item Overflow with flex-wrap

flex-wrap

Fine-tuning Flex Item Placement with align-content

align-content

Box-Shadow vs. Drop-Shadow: How They Are Different?

Box-Shadow vs. Drop-Shadow: How They Are Different?

Attribute Selector in CSS

Attribute Selector in CSS

Managing Flex Item Overflow with flex-wrap

flex-wrap

Fine-tuning Flex Item Placement with align-content

align-content

Tags:

List

Unordered List

Ordered List

Horizontal Rule

HTML & CSS Introduction
Course Content

Chapter 1. Overview of Website Development

How Websites Work?

Designing, Building and Publishing Websites

Designing Websites

Building Websites – Frontend and Backend Coding

Web App vs. Website

Frontend Coding

Web Framework and CMS

Publishing Websites (Hosting Services)

Chapter 2. Preparing for Website Coding

Two Key Tools to Start Coding Websites

How Browsers Display Web Pages

File Name Rules

Website Directory Structure

Absolute Path vs. Relative Path

Chapter 3. HTML Basics

What Is HTML?

HTML Element

Attribute

HTML Document Structure

Layout Semantics

Heading and Paragraph Tag

Text-Level Semantics

Space, Line-break and Tag in Content

Comments in HTML Document

Chapter 4. HTML: Add Links and Images

Overview of Adding Links and Images

Embed Images – <img>

Image File Format

Add Hyperlinks – <a>

Add Hyperlinks to Images

Add Hyperlinks to Specific Location on Web Page

Link Tag – <link>

Script Tag – <script>

Chapter 5. HTML: Create Lists and Tables

Create Lists

Create Tables

Combine Table Cells

Chapter 6. HTML: Create Forms

Create Forms

Create Text Input Forms and Submit Button

Radio Button and Checkbox

Select Box

Labels

Auto Complete and Disabled

Chapter 7. Bridging HTML and CSS

Block Element vs. Inline Element

Nesting Elements – Parent Elements and Child Elements

Div vs. Span

Global Attribute – Class, ID and Style

Accordion – <Details> and <Summary>

Chapter 8. CSS Basics

What Is CSS?

CSS Syntax

Where To Type CSS?

CSS Basic Selectors

Descendant Selector

Inheritance

Specificity

Reset CSS

Browser Developer Tools for CSS

Comments in CSS Document

Chapter 9. Web Design Basics

Design Element Representation in HTML and CSS

Key Design Points by CSS

Length

Color Code – HEX and RGB

Color Theme

Chapter 10. CSS: Sizing and Spacing

CSS Box Model

width and height

padding

margin

Margin and Padding for Specific Side

margin: auto

box-sizing

Chapter 11. CSS: Styling Text and Images

Text Styling Properties

font-size

color

font-family

Web Font and Google Font

font-weight and font-style

text-decoration

line-height and letter-spacing

text-align

vertical-align

Styling Images

float: left and right

Chapter 12. CSS: Styling Backgrounds

background-color

background-image

background-size

background-repeat

background-position

background-attachment

background (Multiple Properties)

Chapter 13. CSS: Styling Borders and Drawing Lines

border-style

border-color

border-width

border-radius

Border (Multiple Properties)

Borders on Specific Side

Border Radius on Specific Side

Chapter 14. CSS: Layout – Key Concepts and Display Property

Layout Before and After

Layout Key Design Points

Display Property

inline, block and inline-block

display: none

Chapter 15. CSS: Layout – Flex Box

Flex Box – display: flex

flex-direction

Main Axis and Cross Axis

flex-wrap

justify-content

align-items

align-content

align-self

flex-grow

flex-shrink

flex-basis

margin: auto with Flex Box

Inline Flex Box

Nested Flex Box

Chapter 16. CSS: Styling Lists

List Styling Properties

list-style-type

list-style-image

list-style-position

Chapter 17. Creating and Styling Components

Components and Layout

Buttons

Cards

Top Bar

Footer and Bottom Bar

Chapter 18. Completing Website Development

Website Structure Design

Live Server

Home (Landing) Page Development

Main (List) Page Development

Content (Detail) Page Development

Chapter 19. Publishing Websites

Key Steps to Publish Websites

Domain and DNS Server

Favicon

GitHub Pages

Chapter 20. Supplemental Topics

Horizontal Rule – <hr>

Line Break – <br>

Reserved Characters and HTML Entities

Non-breaking Space – &nbsp;

Chapter 1. Overview of Website Development

How Websites Work?

Designing, Building and Publishing Websites

Designing Websites

Building Websites – Frontend and Backend Coding

Web App vs. Website

Frontend Coding

Web Framework and CMS

Publishing Websites (Hosting Services)

Chapter 2. Preparing for Website Coding

Two Key Tools to Start Coding Websites

How Browsers Display Web Pages

File Name Rules

Website Directory Structure

Absolute Path vs. Relative Path

Chapter 3. HTML Basics

What Is HTML?

HTML Element

Attribute

HTML Document Structure

Layout Semantics

Heading and Paragraph Tag

Text-Level Semantics

Space, Line-break and Tag in Content

Comments in HTML Document

Chapter 4. HTML: Add Links and Images

Overview of Adding Links and Images

Embed Images – <img>

Image File Format

Add Hyperlinks – <a>

Add Hyperlinks to Images

Add Hyperlinks to Specific Location on Web Page

Link Tag – <link>

Script Tag – <script>

Chapter 5. HTML: Create Lists and Tables

Create Lists

Create Tables

Combine Table Cells

Chapter 6. HTML: Create Forms

Create Forms

Create Text Input Forms and Submit Button

Radio Button and Checkbox

Select Box

Labels

Auto Complete and Disabled

Chapter 7. Bridging HTML and CSS

Block Element vs. Inline Element

Nesting Elements – Parent Elements and Child Elements

Div vs. Span

Global Attribute – Class, ID and Style

Accordion – <Details> and <Summary>

Chapter 8. CSS Basics

What Is CSS?

CSS Syntax

Where To Type CSS?

CSS Basic Selectors

Descendant Selector

Inheritance

Specificity

Reset CSS

Browser Developer Tools for CSS

Comments in CSS Document

Chapter 9. Web Design Basics

Design Element Representation in HTML and CSS

Key Design Points by CSS

Length

Color Code – HEX and RGB

Color Theme

Chapter 10. CSS: Sizing and Spacing

CSS Box Model

width and height

padding

margin

Margin and Padding for Specific Side

margin: auto

box-sizing

Chapter 11. CSS: Styling Text and Images

Text Styling Properties

font-size

color

font-family

Web Font and Google Font

font-weight and font-style

text-decoration

line-height and letter-spacing

text-align

vertical-align

Styling Images

float: left and right

Chapter 12. CSS: Styling Backgrounds

background-color

background-image

background-size

background-repeat

background-position

background-attachment

background (Multiple Properties)

Chapter 13. CSS: Styling Borders and Drawing Lines

border-style

border-color

border-width

border-radius

Border (Multiple Properties)

Borders on Specific Side

Border Radius on Specific Side

Chapter 14. CSS: Layout – Key Concepts and Display Property

Layout Before and After

Layout Key Design Points

Display Property

inline, block and inline-block

display: none

Chapter 15. CSS: Layout – Flex Box

Flex Box – display: flex

flex-direction

Main Axis and Cross Axis

flex-wrap

justify-content

align-items

align-content

align-self

flex-grow

flex-shrink

flex-basis

margin: auto with Flex Box

Inline Flex Box

Nested Flex Box

Chapter 16. CSS: Styling Lists

List Styling Properties

list-style-type

list-style-image

list-style-position

Chapter 17. Creating and Styling Components

Components and Layout

Buttons

Cards

Top Bar

Footer and Bottom Bar

Chapter 18. Completing Website Development

Website Structure Design

Live Server

Home (Landing) Page Development

Main (List) Page Development

Content (Detail) Page Development

Chapter 19. Publishing Websites

Key Steps to Publish Websites

Domain and DNS Server

Favicon

GitHub Pages

Chapter 20. Supplemental Topics

Horizontal Rule – <hr>

Line Break – <br>

Reserved Characters and HTML Entities

Non-breaking Space – &nbsp;