There are two different types of lists we will look at in this tutorial. The first type is an unordered list (bullet list) which is used to list items in no particular order. A bullet list is a dot-point list but you can customise the style of the list to use squares or arrows instead of dots, for example. The second type of list is an ordered list (numbered list) which uses numbers to order items in a list.
An unordered list looks like this:
An ordered list looks like this:
Unordered list items go between the <ul> and </ul> tags in the body section of your webpage. Ordered list items go between the <ol> and </ol> tags on your webpage. Each list item is surrounded by the <li> and </li> tags (you can use <li> in both unordered and ordered lists). Watch the video below and then scroll down to see the code. If you’d like to find out how to style lists with CSS code, you should check out the list styling tutorial.
The sample code below shows how to create ordered lists and unordered lists:
<!DOCTYPE html> <html> <head> <title>Lists</title> <meta charset="utf-8"/> </head> <body> <h3>My bullet list:</h3> <ul> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> </ul> <h3>My numbered list:</h3> <ol> <li>List item 1</li> <li>List item 2</li> <li>List item 3</li> </ol> </body> </html>