HTML <ol> Element

Publish in HTML Tutorial el 25/05/2025 14:03

The <ol> HTML element represents an ordered list of items, typically rendered as a numbered list. Ordered lists are used when the sequence of items is important, such as step-by-step instructions or rankings.


Key features of <ol>:

  • Creates a numbered list by default
  • Can be customized with different numbering styles
  • Supports nested lists (both ordered and unordered)
  • Works with CSS for advanced styling
  • Can be manipulated with JavaScript


Basic Syntax


Rendered Example

Play Code


Examples of <ol> Usage

Example 1: Basic Ordered List

A simple ordered list with default numbering.

Play Code


Example 2: Custom Numbering Type

Using the type attribute to change numbering style.

Play Code


Example 3: Nested Ordered Lists

Creating a hierarchical structure with nested ordered lists.

Play Code


Example 4: Dynamic List with JavaScript

Adding items to an ordered list using JavaScript.

Play Code


Example 5: Reversed Ordered List with JavaScript

Creating and manipulating a reversed ordered list.

Play Code


Tips and Tricks

  • Use the start attribute to begin numbering from a specific value
  • Combine with CSS list-style-type for more numbering style options
  • The reversed attribute will display items in descending order
  • For semantic HTML, use ordered lists only when the sequence matters
  • Consider accessibility - screen readers will announce the number of items


Browser Support

The <ol> element is supported by all browsers and has excellent compatibility across versions. All modern browsers support the main attributes like type, start, and reversed.

También te puede interesar

HTML <style> Element
HTML <style> Element

The <style> HTML element contains style information for a document, or part of a document. ...

HTML <strong> Element
HTML <strong> Element

The <strong> element is used to indicate that its content has strong importance, seriousnes...

HTML <span> Element
HTML <span> Element

The <span> element is an inline container used to mark up a part of a text or document. Unl...

HTML <source> Element
HTML <source> Element

The <source> element is used to specify multiple media resources for media elements like &l...

HTML <small> Element
HTML <small> Element

The <small> element is used to represent side-comments and small print, typically for discl...

HTML <section> Element
HTML <section> Element

HTML <section> Element: The Complete Guide The <section> element is a semantic HTML ...