ul means unorded list. It is for lists in whick it doesn't matter what order the list items are in.
ol means ordered list. It is for lists that are numbered or in some way show that they have a specific ordering.
By default ul gets you bullet pointed lists and ol numbered lists, although this can be edited in css.
UL means "unordered list". OL means "ordered list".
UL gets you bullet points. OL gets you numbers.
Definitely not interchangable.
In math terms (hey, why not?), an <ol>
represents a sequence, whereas <ul>
represents a set. Rearranging the items in an ordered list changes the list's meaning. Rearranging them in an unordered list does not.
This is a good rule-of-thumb for which type of list to use. If changing the order of the items makes the list incorrect, you want to use <ol>
. If the order doesn't matter, use <ul>
.
Haha, so many answers!
When HTML first came out, there were OL and UL, which, as all of the other posters have said, meant Ordered List and Unordered List.
The difference was easy. OLs displayed... a number next to them. Or a roman numeral, or a letter! You could even control whether it used capitalized symbols or lowercase! Cool!
ULs gave you bullets. 3 types of bullets, even - discs (hollow circles), squares (filled squares), circles (filled circles.)
There was no CSS. Beyond these attributes, there wasn't really a way to customize the list formats (and margins and indententations and everything else.) So, this distinction was important.
Nowadays, its all CSS. In fact, the w3 people want you to use styles rather than the html "type" attribute that you used to use. So, using UL vs OL doesn't really matter, if you are one of them newfangled CSS users.
CSS lets you change the bullet type, or opt to use an image, or change the margins/styles/indentations, or not even display a bullet at all.
Edit again: This answer isn't really meant to address the semantic merits of UL vs OL. But technically (you know, at the bits and bytes) the above outlines the differences in behavior.
As the question asks "when to use them", I thought appropriate to offer examples of when, I usually decide to use OL when I want a series of steps, and UL when I want to offer choices:
Ordered list
Here the steps are critical for the business case, we must do the steps in this order, therefore an ordered list is used.
Checkout stages on eCommerce, these steps will be in this order.
<ol>
<li>shipping</li>
<li>billing</li>
<li>summary</li>
<li>confirmation</li>
</ol>
Unordered list
A user may decide on the order they choose to interact with these choices
<ul>
<li>Contact Us</li>
<li>Newsletter Signup</li>
<li>Terms</li>
<li>Log out</li>
</ul>
With <ol>
the order of the data is important and will be displayed (by default) while with <ul>
, order isn't as important.
Example:
<p>Tomorrow I will</p>
<ol>
<li>Wake up</li>
<li>Have breakfast</li>
<li>Go to sleep</li>
</ol>
<p>During breakfast, I will eat</p>
<ul>
<li>Butter</li>
<li>Eggs</li>
<li>Bacon</li>
</ul>