Loading Page Content...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Preparing courses, live labs, and learning resources.सामग्री लोड हो रही है, कृपया प्रतीक्षा करें...
Welcome to Chapter 7: Lists in HTML!
Think about your daily school life. How often do you make lists?
Lists are one of the most natural ways human beings read and organize information. If you put all those items into one long, messy paragraph, nobody will want to read it. But when you break items into clean, neat bullet points or numbered steps, your eyes can scan them in seconds!
In HTML, we have two primary list types to organize our content:
<ul>) — When the order does not matter (bullet points).<ol>) — When the order does matter (numbered 1, 2, 3...).Let's master both!
<ul>) — Bullet Points 🔘Imagine you are packing your school bag for tomorrow. You need:
Does it matter whether you put the water bottle in your bag first or the geometry box first? Not at all! The order doesn't change anything.
Whenever the sequence of items is not important, we use an Unordered List.
<ul> (Unordered List): The outer box or container that holds the list.<li> (List Item): Each individual item inside the list.By default, the browser places a solid black circular bullet point (•) in front of every <li>:
list-style-type) 🎨You can change the shape of the bullet points using the style="list-style-type: ...;" attribute on your <ul>:
<ol>) — Numbered Steps 🔢Now, imagine you are following a recipe to prepare a cup of Hot Masala Chai:
Can you change the order? What if you try to filter before boiling? It would be a total disaster!
Whenever the sequence or ranking matters, we use an Ordered List (<ol>).
The browser automatically numbers each item 1., 2., 3., 4.! You don't have to type the numbers yourself. If you add or remove an item in the middle, the browser automatically recalculates all the numbers for you!
type Attribute 🔤You don't have to settle for just standard 1, 2, 3 numbers! HTML provides the type attribute for <ol>:
| Value | Numbering Style | Example Output | Where It's Used |
|---|---|---|---|
type="1" | Normal Numbers (Default) | 1., 2., 3. | Recipes, daily timetables, rankings |
type="A" | Uppercase Alphabet | A., B., C. | Multiple choice question options |
type="a" | Lowercase Alphabet | a., b., c. | Sub-sections in textbooks |
type="I" | Uppercase Roman Numerals | I., II., III. | Book chapters, major historic eras |
type="i" | Lowercase Roman Numerals | i., ii., iii. | Preface pages, appendix points |
start attribute)What if your exam has two pages, and Question 1 to 5 were on Page 1? On Page 2, you want your list to start directly from 6:
reversed attribute) 🚀Imagine building a space rocket launch countdown or a Top 10 chart:
Have you ever seen Russian Matryoshka nesting dolls—where a small doll sits inside a bigger doll?
In HTML, you can place an entire list inside a list item! This is called a Nested List, and it is how modern computer file managers and syllabus outlines are built.
<ul> or <ol> INSIDE the parent <li> element before closing it </li>!
Don't place a <ul> floating directly between <li> tags!<ul>) vs Ordered (<ol>): Quick Comparison| Feature | Unordered List (<ul>) | Ordered List (<ol>) |
|---|---|---|
| Meaning | Sequence does NOT matter | Sequence DOES matter |
| Default Marker | Black solid bullet point (•) | Arabic numbers (1., 2., 3.) |
| Custom Markers | circle, square, none | type="A", type="a", type="I", type="i" |
| Special Attributes | — | start="5", reversed |
| Common Uses | Shopping lists, navigation menus, features | Instructions, recipes, rank holders, quiz options |
<li> tagYou cannot write plain text directly inside <ul> or <ol>. Every single item must be wrapped inside <li>...</li>!
<ol>Never type 1., 2. yourself inside the <li> tag! The browser does that automatically.
Never put a sub-list outside of an <li>.
<ul> (Unordered List) when the order of items does not matter (renders bullet points).<ol> (Ordered List) when items follow a specific sequence or ranking (renders numbers).<li> (List Item) tag.<ol> supports the type attribute for capital letters (A), small letters (a), Roman numerals (I or i), and normal numbers (1).<ol> supports start="number" to begin counting from a specific number, and reversed for countdowns.<li>.Test your understanding with these multiple-choice questions:
Open VS Code and create a file named my-lists-project.html.
Create a neat "School Activity & Recipe Board" containing:
<ul>) with a square bullet style listing 4 sports items.<ol>) showing the 4 steps to prepare noodles.<ol type="A"> with a question and 4 multiple-choice options.<ol reversed start="5"> counting down from 5 to 1 for a rocket launch!Next Up: In Topic 7.2, we will explore Description Lists (<dl>) — the secret weapon for building glossaries, dictionaries, and FAQ sections!
In the next lesson, we will continue your web development journey with Description Lists (Lists).
Continue learning with hands-on practice, examples, and exercises in the upcoming topic.
| Previous Lesson | Next Lesson |
|---|---|
| Target Attributes & Security | Description Lists |
Test your understanding of this lesson with 5 questions. Each question has one correct answer.