Performance: Ordered lists
Ordered lists affect the browser's rendering speed by adding structured list elements that require layout and paint operations.
<ol><li>Item 1</li><li>Item 2</li></ol>
<ol style="list-style: none; counter-reset: item 0;"><li style="counter-increment: item;">Item 1</li><li style="counter-increment: item;">Item 2</li></ol>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Native <ol> with <li> | Minimal DOM nodes | Single reflow for list | Low paint cost | [OK] Good |
| <ol> with CSS counters on each <li> | More style recalculations | Multiple reflows per item | Higher paint cost | [X] Bad |
<ol>) and unordered (<ul>).<ol> tag creates numbered (ordered) lists, while <ul> creates bullet lists.<ol>. Other tags like <orderedlist> or attributes on <ul> are not valid HTML.<ol> without extra attributes or incorrect tag names.<ol> <li>First</li> <li>Second</li> <li>Third</li> </ol>
<ol> and <li> relationship<ol> tag creates a numbered list, and each <li> is a list item.<ol> <li>Step 1</li> <li>Step 2</li> <li>Step 3</ol> </li>
<li> must open and close inside the <ol>. Here, the last </li> is after </ol>, which breaks proper nesting.<ol> tag to do this?start attribute on <ol> sets the first number in the list.start="5" will make the list begin numbering at 5.Pass the test and this pattern moves unknown