Performance: Unordered lists
Unordered lists affect the DOM size and rendering time, especially with many list items.
<ul> <li>Item 1</li> <li>Item 2</li> <!-- only 10 items shown, others loaded on demand --> </ul>
<ul> <li>Item 1</li> <li>Item 2</li> <!-- repeated 1000 times --> </ul>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Large unordered list (1000 items) | 1001 nodes | Many reflows | High paint cost | [X] Bad |
| Small unordered list (10 items) | 11 nodes | 1 reflow | Low paint cost | [OK] Good |
<ul> creates unordered lists with bullet points, while <ol> creates ordered lists with numbers.<ul> is specifically for unordered lists.<li> tags.<li> tags go inside the <ul> tags, not the other way around.<ul> <li>Apple</li> <li>Banana</li> <li>Cherry</li> </ul>
<ul> tag creates an unordered list which shows bullet points.<li> creates a bullet point with the text inside it.<ul> <li>First</li> <li>Second </ul>
<li> has a closing tag, but the second <li> does not.<li> must have a closing </li> tag to be valid.<li> of the parent list.<ul> inside the <li> for 'Fruits'. Other options either miss closing tags or place nested lists incorrectly.Pass the test and this pattern moves unknown