Workers:

Ordered-List

An ordered list is a fundamental HTML structure used to present items in a specific, meaningful sequence. Unlike unordered lists, ordered lists convey an inherent order steps in a process, ranked items, or chronological events. This article explains what ordered lists are, when to use them, how to create and style them in HTML/CSS, accessibility considerations, and practical examples.

What is an ordered list?

An ordered list is represented by the

    element in HTML. Each list item is wrapped in an

  1. element

When to use ordered lists

  • Step-by-step instructions (recipes, tutorials, installation guides)
  • Ranked or prioritized items (top 10 lists, leaderboards)
  • Chronological sequences (timelines, historical events)
  • Any content where the order matters

Basic syntax

html
<ol><li>First item</li>  <li>Second item</li>  <li>Third item</li></ol>

Customizing markers

You can change marker type using the type attribute or CSS list-style-type.

HTML type attribute (limited options):

html
<ol type=“A”>  <li>Item A</li>  <li>Item B</li></ol>

CSS options (more control):

css
ol {  list-style-type: lower-roman; /* i, ii, iii */}

For custom markers, hide default markers and use counters:

css
ol.custom {  counter-reset: item;  list-style: none;  padding-left: 0;}ol.custom li {  counter-increment: item;  margin: 0 0 0.5em 0;  padding-left: 2em;  position: relative;}ol.custom li::before {  content: counter(item) ”.”;  position: absolute;  left: 0;  font-weight: bold;}

Nested ordered lists

Ordered lists can be nested for multi-level sequences. Use CSS to adjust numbering style per level.

html
<ol>  <li>Step one    <ol>      <li>Substep a</li>      <li>Substep b</li>    </ol>  </li>  <li>Step two</li></ol>

Accessibility

  • Use semantic HTML (
      and

Use with JavaScript

You can manipulate ordered lists dynamically:

html
<ol id=“steps”></ol><script>  const steps = [‘Install’, ‘Configure’, ‘Deploy’];  const ol = document.getElementById(‘steps’);  steps.forEach(text => {    const li = document.createElement(‘li’);    li.textContent = text;    ol.appendChild(li);  });</script>

SEO and content structure

Ordered lists can help search engines understand structure and sequence. Use them for how-to content, numbered instructions, and any ordered data.

Conclusion

Ordered lists are a simple yet powerful tool for conveying sequence and priority. Use semantic HTML, style thoughtfully with CSS, and keep accessibility in mind when customizing markers or behavior.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *