In HTML, what do the <ol> attributes start, reversed and type do, and what does the value attribute on an <li> change?
answer
- ordinals belong in markup, not in item text
- one attribute shifts the whole sequence
- one boolean flips the direction
- a per-item override that later items inherit
- five marker series, only on the ordered list
basics
~20 sstart sets the ordinal of the first item, reversed counts down instead of up, and type chooses the marker series (1, a, A, i, I). value on an <li> overrides that one item's ordinal, and later items continue counting from it.
solid answer
~40 s`<ol start="5">` begins numbering at 5 instead of 1, which is how you continue a list that was interrupted by a paragraph or split across pages. `reversed` is a boolean attribute that makes the list count down; combined with `start` the first item takes the start value, and without `start` the first item's number is the item count. `type` selects the marker series: `1` decimal, `a`/`A` latin letters, `i`/`I` roman numerals. On an individual `<li>`, `value="12"` sets that item's ordinal outright, and every following item continues from there — handy for a step list that skips numbers. `value` only has an effect inside an `<ol>`. All of these are structural: the ordinals live in the markup, reflected as `HTMLOListElement.start` and `HTMLLIElement.value`, rather than being invented at render time.
code
html · 5 lines<ol reversed start="3">
<li>Bronze</li>
<li>Silver</li>
<li value="1">Gold</li>
</ol>go deeper
Know that <ol> numbers itself and that start changes where the numbering begins, and never type ordinals into the item text by hand.
Explain each attribute's exact effect, including that reversed without start begins at the item count and that value on one item shifts every item after it.
Judge when ordering is genuinely semantic versus decorative, and spot templates that hand-write numbers or misuse value on every item as a sign the data model, not the markup, should produce the sequence.
Set the convention for numbered content across a documentation or product surface, so ordinals stay authored in structure and remain stable as content is split, reordered, or translated.
## Why ordinals are markup, not decoration An `<ol>` differs from a `<ul>` in exactly one way that matters: the order of its items is part of the meaning. Steps in a recipe, finishing positions in a race, and chapters of a document are ordered lists; a set of tags or navigation links is not. Because the order carries meaning, HTML gives you attributes to control the *numbers themselves*, not just how they look. ## start `start` takes a valid integer and sets the ordinal of the first item. ```html <ol start="4"> <li>Rinse the beans</li> <!-- 4 --> <li>Grind coarsely</li> <!-- 5 --> </ol> ``` The classic use is a list interrupted by explanatory prose: you close the first `<ol>` after step 3, write a paragraph, then open `<ol start="4">`. The alternative — typing "4." into the item text — produces a number that is content rather than structure, so it survives copy-paste but breaks the moment a step is inserted, and it doubles up with the marker the browser already draws. `start` is reflected by the DOM property `HTMLOListElement.start`. ## reversed `reversed` is a boolean attribute: present means the list counts down. ```html <ol reversed> <li>Third place</li> <!-- 3 --> <li>Second place</li> <!-- 2 --> <li>Winner</li> <!-- 1 --> </ol> ``` With no `start`, the first item's number equals the number of items in the list, so a three-item reversed list runs 3, 2, 1 — the countdown you want for a top-N list written worst-first. Add `start` and the first item takes that value instead, so `<ol reversed start="10">` runs 10, 9, 8… That combination is how a "top 10" list rendered in ascending drama order gets its numbers right without any scripting. ## type `type` chooses the marker series and takes one of five values: `1` (decimal, the default), `a` (lowercase latin letters), `A` (uppercase latin), `i` (lowercase roman numerals), `I` (uppercase roman). `<ol type="A">` produces A, B, C. The attribute is valid on `<ol>`. It is *not* valid on `<ul>` or on `<li>` — the old `type` attribute on those elements is obsolete, and bullet shape is a styling concern. Use `type` on `<ol>` when the numbering style is part of the content's meaning (a legal document whose clauses are cited as "clause (iv)"), and leave purely decorative marker choices to the stylesheet. ## value on <li> `value` takes an integer and sets that specific item's ordinal. Crucially, the items after it continue from the new number rather than resuming the old sequence: ```html <ol> <li>One</li> <!-- 1 --> <li value="10">Ten</li> <!-- 10 --> <li>Eleven</li> <!-- 11 --> </ol> ``` That makes it the tool for a list with a deliberate gap — showing steps 1, 2, then jumping to 7 in an abridged tutorial, or reproducing a numbered source document faithfully. `value` has no effect on an `<li>` whose parent is a `<ul>`; it is reflected as `HTMLLIElement.value`. ## What this is not Two boundaries are worth stating in an interview. First, these attributes control the *ordinal*, and the marker glyph you see is drawn by the browser from that ordinal — how the marker is styled belongs to CSS, and a stylesheet can suppress markers entirely without changing the ordinals in the DOM. Second, none of this is a reason to hand-write numbers into item text. Markup-driven ordinals renumber automatically when items are inserted, removed, or reordered by a template, which is precisely the class of bug hand-typed numbers create. ## Choosing between them in practice Reach for `start` when a single list is split by other content; `reversed` when the semantic order is descending; `value` when one item's number is an exception rather than the whole sequence; and `type` only when the numbering style itself is meaningful. If you find yourself using `value` on most items, the list is probably not really an ordered list — or the data, not the markup, should be producing the sequence.
- If a <ul> is given the same start and reversed attributes, what happens?Nothing useful — `start`, `reversed`, and `type` are defined on `<ol>`, and an unordered list has no ordinals for them to affect. The browser simply ignores them as unknown attributes on that element. If the sequence matters, the element itself is wrong: switch to `<ol>`.
- Why prefer <ol start="4"> over typing "4." at the start of the item's text?Because the ordinal stays structural. With `start`, inserting or removing a step renumbers everything automatically, the DOM exposes the value via `HTMLOListElement.start`, and no duplicate number appears next to the browser-drawn marker. Hand-typed numbers go stale the first time the list changes.
- How does a reversed list decide the first item's number when no start attribute is given?It uses the number of items in the list. A five-item `<ol reversed>` runs 5, 4, 3, 2, 1. Adding `start` overrides that, so `<ol reversed start="10">` begins at 10 and counts down regardless of how many items follow.
saying these in an interview costs you the question
- Thinks reversed just flips the visual order of items
- Types the numbers into the item text instead
- Believes type is still valid on ul or li
- Assumes value on one item only affects that item
- Uses ol for an unordered set because it looks tidier