HTML Lists

Lists organize related content. HTML provides three types: unordered lists (bullet points), ordered lists (numbered), and definition lists (term + description).

Unordered Lists

<ul> (unordered list) combined with <li> (list item) creates bullet-point lists — ideal for menus, categories, feature lists, and other content without a required sequence:

Example

HTML
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
▶ Try it Yourself

Ordered Lists

<ol> (ordered list) generates numbered items — ideal for step-by-step instructions, rankings, and procedural guides:

Example

HTML
<ol>
<li>Open your editor</li>
<li>Write some HTML</li>
<li>Save as an .html file</li>
<li>Open in your browser</li>
</ol>
▶ Try it Yourself
📌 Nested Lists: Lists can be nested inside one another — place a <ul> or <ol> inside an <li> to create multi-level hierarchies. Multi-level dropdown navigation menus are built using nested lists.

Definition Lists

<dl> (definition list) contains a series of <dt> (terms) and <dd> (descriptions), ideal for glossaries, metadata, and Q&A formats:

Example

HTML
<dl>
<dt>HTML</dt>
<dd>HyperText Markup Language, the skeleton of web pages</dd>
<dt>CSS</dt>
<dd>Cascading Style Sheets, controlling the look of web pages</dd>
</dl>
▶ Try it Yourself

Collapsible Lists

<details> and <summary> are HTML5 tags for creating expandable/collapsible content blocks — commonly used for FAQ sections and collapsible documentation menus. Click the <summary> heading to toggle the expand/collapse state:

Example

HTML
<details>
<summary>What is HTML?</summary>
<p>HTML is the HyperText Markup Language used to create web pages.</p>
</details>

<details open>
<summary>What is CSS?</summary>
<p>CSS controls the styling and layout of web pages.</p>
</details>
▶ Try it Yourself
📌 The open Attribute: Adding the open attribute to <details> makes the content expanded by default (with open = expanded; without = collapsed). Browsers automatically add an expand/collapse arrow to <summary> — no extra CSS or JavaScript needed.

❓ FAQ

Q What's the difference between <ul> and <ol>? When should I use each?
A <ul> is an unordered list — marked with bullets, squares, or other symbols — suitable for items with no sequence, like navigation menus, feature lists, or key points. <ol> is an ordered list — marked with numbers or letters — suitable for items with a specific order, like step-by-step instructions, rankings, or tutorial outlines. Choose based on whether the items have a sequential relationship.
Q Can lists be nested? How many levels deep?
A Yes, and there's no limit. Place a <ul> or <ol> inside a <li> to create sublists. Common scenarios: multi-level directories, tree menus, outline structures. However, keep it to 3-4 levels max — deep nesting hurts readability and displays poorly on mobile. You can mix <ul> and <ol> when nesting, like ordered outer with unordered inner.
Q What is a <dl> definition list? How does it differ from <ul>/<ol>?
A <dl> (Definition List) is designed for term-description pairs, composed of <dt> (term) and <dd> (description). Typical scenarios: FAQs, glossaries, product specs, metadata. <ul>/<ol> are collections of "list items," while <dl> is a collection of "key-value pairs." In HTML5, <dl> can also be used for author information, contact details, and other metadata.

📖 Summary

📝 Exercises

  1. Build a menu: Use an unordered list to create a site navigation menu with links for Home, Products, About Us, and Contact.
  2. Nested lists: Create a nested list: an outer ordered list (steps) with an inner unordered list (notes for each step).
100%

🙏 帮我们做得更好

我们是刚上线的编程教程站,几个人的小团队,精力有限。页面虽经检查,难免还有疏漏——链接失效、排版错乱、内容有误、语言生硬……

如果您发现了,麻烦告诉我们,我们会在收到反馈后第一时间进行修复,再次感谢您的光临 🙏