Lists
« Previous: Links | Next: Tables »
HTML allows you to create ordered, unordered and definition lists.
<ol>
You can create ordered lists using the <ol> tag.
| Code | Output |
|---|---|
<ol> |
|
<ul>
Unordered lists are created using the <ul> tag.
| Code | Output |
|---|---|
<ul> |
|
<li>
The <li> tag defines a list item. The <li> tag is used in both ordered (<ol>) and unordered lists (<ul>).
The <li> element can contain many other elements including headings, paragraphs and other lists:
| Code | Output |
|---|---|
<ul> |
|
Remember, though, that everything inside an ordered or unordered list must be contained inside <li> tags - you cannot put anything between or outside of list items.
For example,
<ul>Elephants<li>Wildebeest</li></ul>
is wrong because ‘Elephants’ is not contained within <li> tags.
Remember also to keep your tags properly nested - if you open any tags within a list item, these tags should always be closed before the closing <li>.
<dl>, <dt> and <dd>
These tags are used to create definition lists; these work slightly differently from ordered and unordered lists, and are far less common than the other two types, so I will leave them for you to research if you’re interested: you can find all the relevent information at www.w3schools.com/tags/.