HTML Lists
Table of Content:
There are many reasons you might want to add a list to your pages, from putting your five favorite albums on your homepage to including a numbered set of instructions for visitors to follow:
You can create four types of lists in HTML:Unordered lists: which are like lists of bullet points.
Ordered lists: which use a sequence of numbers or letters instead of bullet points.
Definition lists: which allow you to specify a term and its definition.
Nested Lists: which allow you to specify a lists inside lists.
Unordered lists
<ul>
Element to Create Unordered Lists
<ul>
element: which stands for unordered list.
<li>
element: the li stands for list item.
- Bullet point number one
- Bullet point number two
- Bullet point number three
Live Preview
Example - Disc
List of Language:
- HTML
- C Programming
- Java Programming
Live Preview
Example - Circle
List of Books:
- Solution of Life
- Mother
- Education life and achievemens
Live Preview
Example - Square
List of Reason to live life:
- smile
- help
- love
- sacrifice
- forgiveness
Live Preview
Example - None
Steps to Change Your Life
- Define success
- Visualize that success
- Forget entitlement
- Think small to think big
- Consistency is key
- Prioritize
- Delegate
- Find collaborators
- Stay motivated
- Take stock and try again tomorrow
Live Preview
Unordered HTML List - Choose List Item Marker
The CSS list-style-type property is used to define the style of the list item marker:
Value | Description |
---|---|
disc | Sets the list item marker to a bullet (default) |
circle | Sets the list item marker to a circle |
square | Sets the list item marker to a square |
none | The list items will not be marked |
Ordered lists
Sometimes, you want your lists to be ordered. In an ordered list, rather than prefixing each point with a
bullet point, you can use either numbers (1, 2, 3), letters (A, B, C), or Roman numerals (i, ii, iii) to prefix
the list item.
An ordered list is contained inside the <ol>
element. Each item in the list should then be nested inside
the <ol>
element and contained between opening <li>
and closing </li>
tags
Example - None
- Point number one
- Point number two
- Point number three
Live Preview
Type | Description | Example |
---|---|---|
type="1" | The list items will be numbered with numbers (default) | 1, 2, 3, 4, 5 |
type="A" | The list items will be numbered with uppercase letters | A, B, C, D, E |
type="a" | The list items will be numbered with lowercase letters | a, b, c, d, e |
type="I" | The list items will be numbered with uppercase roman numbers | I, II, III, IV, V |
type="i" | The list items will be numbered with lowercase roman numbers | i, ii, iii, iv, v |
Example - Numbers:
List of Bad habits:
- Swearing
- Trichotillomania
- Picking Your Nose
- Smoking Cigarettes
- Biting Fingernails
- Drinking Coffee
- Drinking Tea
- Hair picking
- Watching Reality Television
- Eating Fast Food
Live Preview
Example - Uppercase Letters:
List of Bad habits:
- Alcohol (if you think you may be an alcoholic, please get professional help)
- Emotional Shopping
- Spending On Credit Cards
- Eating Candy
- Eating White Sugar
- Eating Chocolate
- Drinking Soda/Pop
Live Preview
Example - Lowercase Letters:
List of Bad habits:
- Obsessively Checking iPhone/iPad
- Eating Meat
- Video Games
- Cracking Your Knuckles
- Speaking With Your Mouth Full
- Talking To Yourself
- Using Slang
- Eating Dairy
- Eating Gluten
- Picking Your Teeth In Public
Live Preview
Example - Uppercase Roman Numbers:
List of Bad habits:
- Forgetting To Shave
- Going To The Club
- Using Your Maiden Name
- Humming To Yourself
- Excessive Salt
- All Work And No Play
- Chewing Gum
- Smoking cigarettes
- Biting Your Pen
- Nibbling While Cooking
Live Preview
Example - Lowercase Roman Numbers:
List of Bad habits:
- Overspending
- Overeating
- Snacking
- Hair Picking
- Skin Picking
- Not Holding Eye Contact
- Interrupting Someone
- Sleeping-in
- Skipping The Gym
- Smoking
Live Preview
Using the start Attribute to Change the Starting Number in Ordered Lists (Deprecated)
If you want to specify the number that a numbered list should start at, you can use the start attribute
on the <ol>
element. The value of this attribute should be the numeric representation of that point in the
list, so a E in a list that is ordered with capital letters would be represented by the value 5
Example
List of Bad habits:
- Saying “Ummm” And “Ahhh”
- Saying Lie
- Staying Up Late
- Sleeping With Makeup
- Lying
- Overmedicating
- Playing Kingdom Rush
- Eating Too Fast / Not Chewing
- Skipping Breakfast
- Not Protecting Yourself From The Sun
Live Preview
Definition Lists
The definition list is a special kind of list for providing terms followed by a short text definition or description for them. Definition lists are contained inside the
<dl>
element. The <dl>
element then
contains alternating <dt>
and <dd>
elements. The content of the <dt>
element is the term you will be
defining. The <dd>
element contains the definition of the previous <dt>
element. For example, here is a
definition list that describes the different types of lists in HTML.
Example
- Unordered List
- A list of bullet points.
- Ordered List
- An ordered list of points, such as a numbered set of steps.
- Definition List
- A list of terms and definitions.
Live Preview
Nesting Lists
List can be nested (lists inside lists):
Example
- Item one
- Item two
- Item three
- Item four
- Item 4.1
- Item 4.2
- Item 4.3
- Item Five
Live Preview
Note: List items can contain new list, and other HTML elements, like images and links, etc.
Example
- Coffee
- Tea
- Black tea
- Green tea
- Milk