tags:

views:

1773

answers:

9

Seems interchangable?

+15  A: 

UL means "unordered list". OL means "ordered list".

UL gets you bullet points. OL gets you numbers.

Definitely not interchangable.

Randolpho
Well, technically you can change how the list appears with CSS (list-style). But yes, semanticaly, UL should be used for unordered data and OL for ordered.
jimr
Very true. CSS is just the display of the data; it's the semantic difference that's important, IMO.
Randolpho
-1 — The fact that the default display is different should have no bearing on which you choose to use. I'll cancel the downvote if the bit about display is removed or clarified.
Ben Blank
Of course the default display is a consideration! Not as important as the semantic meaning of a tag, perhaps, but who wants to spend their time changing OL's to have bullet points, and force every developer after you to figure out your bizarre display rules for standard tags? Pedant fail.
Joel Mueller
Hear hear, Joel! My thoughts exactly.
MarquisDeMizzle
@Joel — Wait, what? How is using an ordered list for ordered data and an unordered list for unordered data "bizarre"? Wouldn't someone using the tags incorrectly be more likely cause later developers to have to mess around with counter-intuitive styling?
Ben Blank
@Ben Blank: It's not. That's what's semantically important. But if you use an ordered list for unordered data, then use CSS to make the ordered list act like an unordered list, you have failed, hard. That was my point. The semantics is what's important, even if CSS can modify the display. The semantics are what will be used for automated analysis, for example, not the CSS. You think Google is going to parse the CSS to find out if your ordered list is actually an unordered one? Ok, maybe the would, but that's Google. :)
Randolpho
@Randolpho — Using "an ordered list for unordered data" is exactly what I'm arguing against. I don't disagree with your answer at all; y only problem is that it makes the numbers/bullets sound like the most important part. Perhaps the comment I left was unclear (and if so, I apologize), but I'm trying to argue in *favor* of semantics, here. :-)
Ben Blank
Looks like we're all on the same page. Hurray! Semantics are what's important. I apologize if my post implies otherwise.
Randolpho
@Randolpho — Based on how much negative feedback I'm getting, perhaps I'm the only one that read it that way?  :-)  To clarify further, of the top-voted answers here, yours is the only one which doesn't specifically mention order of data (it just defines the tags) and the only one which *does* specifically mention display. I'll cancel my downvote, but I still think it would be great to see that clarified.  As the top-voted (and soon-to-be-accepted, I suspect) answer, I'd hate for the emphasis to be in the wrong place.
Ben Blank
MarquisDeMizzle
So, an honest question: who actually cares about the semantics? eg, @Randolpho, is there evidence that google actually does something different because of an OL versus UL tag? If not... then what does it matter? Is that why - semantic clarity - there was originally a difference in UL and OL?
rascher
@Ben Blank: My only objection was to the idea that the default display should have "no bearing" on your choice. It should not be the primary consideration, but to say that the default display doesn't even enter into the picture implies that you intend to contravene the default display in a way that could confuse later developers.
Joel Mueller
@Joel — I disagree. If anything, saying it has no bearing should imply that you're most likely not to fiddle with it at all. Why should you? It has no bearing! :-)
Ben Blank
@Joel — Also, I'm curious: you keep saying display only shouldn't be "primary". Can you give me an example of a case where the semantics are so unclear that display *should* influence your decision?
Ben Blank
Ben, I think we must be talking past each other somehow. If the default manner of display for a given tag is of no interest to me, it's probably because I intend to override the default display. If I don't plan on fiddling with the default display, then what the output is going to look like by default will be one of my considerations, in addition to tag semantics - particularly if more than one tag is a valid choice from a semantic point of view.
Joel Mueller
+5  A: 

OL:

  1. List item 1
  2. List item 2

UL:

  • List item 1
  • List item 2

OL is ordered list, UL is unordered list

Zach
For OL,is the number possible to hide?
Shore
As mentioned in the other posts you can use css list-style: none; to hide it. Can also use list-style-type to mess with the look. If you're going to downvote leave a reason.
Zach
Got it.And what if I want to set the margin between each UL element?
Shore
in a simple html page, css, margin-bottom on the li tag could do it
Zach
By the way, the left margin on lists is actually a left padding in most browsers. Best to set `margin:0; padding:0;` if you want to remove it.
DisgruntledGoat
+11  A: 

One is ordered list (OL), it is for things that have a defined and distinct order. There is a reason behind why they are organized.

The other (UL) is unordered list, which is just a collection of things in no specified order. Their organization is trivial.

Ian Elliott
Yep. What the others don't mention is that the numbers or bullets are just the default formatting. The semantic meaning is the main thing.
Rich Bradshaw
BTW,how to hide the bullets of UL by css?
Shore
list-style: none;
Ian Elliott
list-style: none
Barry Brown
list-style: none
victor hugo
list-style: none;
Joey Robert
list-style: none;
Tyler McHenry
There's a point where this argument breaks down, from a semantics perspective. While unordered lists represent a set, rather than a sequence, they implicitly have an "order" - the order in which the list items appear. They are not entirely unordered at all, and the developer - perhaps subconsciously - orders list items upon entry.
scottburton11
+4  A: 

I think it's a sematic issue, as the numbering/bullet points can be changed by CSS.

Ordered lists should be things like instructions, or any sequential information.

Unordered lists should be everything else.

mgroves
Beat me to it. Thanks for bringing up semantics.
Matthew Vines
+6  A: 

With OL the order of the data is important and will be displayed (by default) while with UL not. Example:

<p>Tomorrow wi will</p>
<ol>
 <li>Wake up</li>
 <li>Have breakfast</li>
 <li>Go to sleep</li>
</ol>
<p>During breakfast we will eat</p>
<ul>
 <li>Butter</li>
 <li>Spam</li>
 <li>Sweet spam</li>
</ul>
Ore
+2  A: 

Use OL when you're listing steps that need to be done in a certain order. Use UL when you're listing items in no particular order of importance.

joebert
A: 

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.

rascher
The correct is to make the distinction because you don't know how the user will reach the information. Maybe his browser doesn't support CSS or he's using a screen reader, or whatever. Semantically they are not the same, so you have to distinguish them.
Ore
+4  A: 

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>.

Ben Blank
A: 

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.

Andrew Marsh