HTML & CSS Interview Question #14

What are HTML lists and when would you use them?

HTML Fundamentals, Structure, Semantics, Links, Images, Tables & Forms Junior Beginner

Quick Interview Answer

HTML provides unordered lists with ul, ordered lists with ol, and description lists with dl. li represents an item in an ordered or unordered list, while dt and dd represent terms and descriptions in a description list.

Detailed Explanation

HTML provides unordered lists with ul, ordered lists with ol, and description lists with dl. li represents an item in an ordered or unordered list, while dt and dd represent terms and descriptions in a description list.

Use lists when content is logically a collection of related items. Correct list markup provides meaningful structure instead of manually creating bullets or numbers with plain text.

Code Example

<ul>
    <li>C#</li>
    <li>SQL Server</li>
    <li>JavaScript</li>
</ul>

<ol>
    <li>Clone repository</li>
    <li>Build project</li>
    <li>Run tests</li>
</ol>