Search code examples
htmlsemantic-markup

HTML - Markup for ordered list with numbers?


This is kinda stupid question but what markup should I use for ordered list which already has numbers? I'm currently using <OL> tag but It's kinda redundant in my eyes.

Markup:

<ol>
    <li>Chapter 1</li>
    <li>Chapter 2</li>
    <li>Chapter 3</li>
    <li>Chapter 4</li>
</ol>

Output:

1. Chapter 1
2. Chapter 2
3. Chapter 3
4. Chapter 4

For some reason I'm not using CSS so styling the <OL> is my last option.


Solution

  • <ol> is your best option from a semantical point of view. According to the w3 specifications, you shouldn't use the type attribute anymore but use CSS styling instead:

    http://www.w3.org/TR/html401/struct/lists.html#type-values

    Having said this, <ol> + CSS is the "best" option. But using <ul> instead, might be the "most pragmatic" one, to avoid styling in your specific case.

    UPDATE: Actually, the type attribute was "undeprecated" again in HTML5:

    http://dev.w3.org/html5/markup/ol.html