Lists
Lists help organize information
clearly on a webpage. There are two main types of lists in HTML:
1.
Unordered List (<ul>)
- Displays items with bullets (dots).
- Use it when the order of items doesn't matter.
Example:
<ul>
<li>HTML</li>
<li>CSS</li>
<li>JavaScript</li>
</ul>
How it looks:
- HTML
- CSS
- JavaScript
2.
Ordered List (<ol>)
- Displays items with numbers or letters.
- Use it when the order or sequence matters.
Example:
<ol>
<li>Open your text editor</li>
<li>Write HTML code</li>
<li>Save the file</li>
<li>View it in the browser</li>
</ol>
How it looks:
- Open your text editor
- Write HTML code
- Save the file
- View it in the browser
3.
List Item (<li>)
- Represents each item in both ordered and unordered
lists.
- Must be placed inside <ul> or <ol> tags.
Example
Page to Try (with XAMPP/WAMP)
Create a file named lists.html and paste:
<!DOCTYPE
html>
<html>
<head>
<title>HTML Lists Example</title>
</head>
<body>
<h2>Unordered List Example</h2>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Cherry</li>
</ul>
<h2>Ordered List Example</h2>
<ol>
<li>Wake up</li>
<li>Brush Teeth</li>
<li>Have Breakfast</li>
</ol>
</body>
</html>
Open it via your local server (http://localhost/lists.html) and see the difference between unordered and ordered
lists.