Home 〉 HTML Tutorials 〉 HTML List Tags - ul, ol, li Tags Explained with Examples
HTML List Tags - ul, ol, li Tags Explained with Examples !
Want to learn how to display clean and organized lists in HTML?
This blog post on the HTML list tag explains the use of '<ul>', '<ol>', and '<li>' tags with syntax, examples, attributes, and styling. We've also discussed whether they are block-level or inline elements and how to use them in real-world scenarios. You also got a quick intro to description list tags like '<dl>', '<dt>', and '<dd>' - which we've covered in another blog post. Using proper SEO keywords and structure will help this post rank high in search results. This detailed blog post on HTML list tag is as follows.
HTML List tags are used to display lists of items in web pages. Lists help organize content for better readability and structure. In HTML, you can create ordered lists, unordered lists, and description lists (covered in a separate post).
In this blog post, we'll focus on:
We'll also give a brief mention of the '<dl>', '<dt>', and '<dd>' tags used for description lists, which we've explained in a [separate tutorial on HTML Description Tag].
Syntax ✍
<ul>
<li>Item One</li>
<li>Item Two</li>
</ul>
<ol>
<li>Step One</li>
<li>Step Two</li>
</ol>
They all start on a new line and take up full width by default.
Defines the numbering type.
<!DOCTYPE html>
<html>
<body>
<ol type="A">
<li>Apple</li>
<li>Banana</li>
</ol>
</body>
</html>
output 📌
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
This will display list items with uppercase letters (A, B, C...).
Specifies the starting number for an ordered list.
<!DOCTYPE html>
<html>
<body>
<ol start="5">
<li>Point Five</li>
<li>Point Six</li>
</ol>
</body>
</html>
output 📌
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
List will start from 5 instead of 1.
Displays the list in reverse order.
<!DOCTYPE html>
<html>
<body>
<ol reversed>
<li>Final</li>
<li>Mid</li>
<li>Start</li>
</ol>
</body>
</html>
output 📌
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Displays: 3. Final, 2. Mid, 1. Start
Applies inline CSS to customize the list's appearance.
<!DOCTYPE html>
<html>
<body>
<ul style="background-color: #f0f0f0; padding: 10px; border-radius: 8px;">
<li style="color: #333; font-size: 16px;">List Item One</li>
<li style="color: #555; font-size: 16px;">List Item Two</li>
</ul>
</body>
</html>
output 📌
You can Try the above code by changing the values in our user-friendly code editor by clicking the "Try It" button and see the output of the same.
Adds padding, background color, rounded corners, and text color to enhance visuals.
Please also refer to our post on HTML Description List Tag - Learn '<dl>', '<dt>', '<dd>' with Syntax, Attributes & Examples
HTML list tags ('<ul>', '<ol>', and '<li>') are essential for displaying content in a structured format. Whether you're creating navigation menus, process steps, or feature lists - list tags are the go-to option. With optional attributes and CSS styling, you can enhance the appearance and functionality of your lists easily.
A '<ul>' creates a bulleted list, while an '<ol>' creates a numbered list.
Yes, you can nest '<ul>' or '<ol>' tags inside '<li>' elements.
No, '<li>' must be placed inside either '<ul>' or '<ol>' tags.
Yes, using inline or external CSS you can style lists with color, font, padding, margin, etc.