HTML <ol> Tag
The <ol> tag creates an ordered (numbered) list. It contains one or more <li> (list item) elements. Ordered lists are used when the order of items matters, like steps in a process or rankings.
Automatic Numbering
The <ol> tag automatically numbers its list items. By default, items are numbered 1, 2, 3, etc. You can customize numbering with the type attribute (1, A, a, I, i) and start with the start attribute. Each <li> represents one item in the list.
Common Use Cases
Common use cases include: step-by-step instructions, rankings, numbered sequences, and any content where order matters. Ordered lists provide semantic meaning and help screen readers understand the sequence. They're essential for accessibility.
Best Practices
Use <ol> when the order of items matters. Use <ul> for unordered (bulleted) lists. Always include list items (<li>) inside the list. Ensure proper semantic structure for accessibility. Consider using CSS to style the list appearance.
