Chuck's Academy

Basic HTML

Lists in HTML

Unordered Lists (<ul>)

An unordered list is a collection of items without a specific order. In HTML, the <ul> tag is used along with the <li> tag for each list item. These lists are typically represented with bullets on the page.

html
"This is an example of an unordered list. Each item, wrapped in the li tag, will appear with a bullet, displaying three fruit items."

Ordered Lists (<ol>)

Unlike unordered lists, ordered lists use numbers or letters to indicate the order of items. To create an ordered list, we use the <ol> tag.

html
"In this example of an ordered list, each step of the recipe is numbered, making it easier to follow the instructions."

List Items (<li>)

The <li> tags are used within the list tags (<ul> or <ol>) to define each individual list item. Lists can contain text, links, and even other lists.

html
"This example shows a nested list. Under the fruits item, there is a sublist with types of fruits. The same goes for vegetables."

Description Lists (<dl>, <dt>, <dd>)

Description lists are useful for defining terms and descriptions. We use the <dl> tag to start the list, <dt> for each term, and <dd> for its description.

html
"Here, we use a description list to define the terms HTML and CSS. Each term is followed by its corresponding description."

Grouping Elements (<div> and <span>)

In HTML, the <div> and <span> tags are used for grouping and styling other elements. <div> is a block-level container, ideal for grouping entire sections. On the other hand, <span> is an inline container, used to apply styles to parts of text.

html
"In this example, the div contains a heading and a paragraph, forming a news section. The span is used to change the color of a specific word within a paragraph."

Chapter Conclusion

Now that you understand how to use lists and grouping elements, you can structure the content of your web pages in a clear and organized manner. In the next chapter, we will learn about links and navigation in HTML.


Ask me anything