Performance: Semantic elements and screen readers
This concept affects how quickly screen readers can interpret and navigate page content, impacting accessibility and user experience for assistive technology users.
<header>Welcome to our site</header> <main>Here is the main content</main>
<div>Welcome to our site</div> <div>Here is the main content</div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Using <div> for all content | Minimal DOM nodes | 0 reflows | Minimal paint | [X] Bad for accessibility |
| Using semantic elements like <header>, <main> | Minimal DOM nodes | 0 reflows | Minimal paint | [OK] Good for accessibility |
<main> element specifically marks the main content unique to the page, guiding screen readers effectively.<nav> element is the standard semantic tag for navigation menus.<nav> ... </nav> is valid HTML5 syntax recognized by screen readers.<header> <h1>Welcome</h1> </header> <main> <p>Hello world!</p> </main>
<header> contains an <h1> with "Welcome", so it reads this first.<div role='main'> <h2>Content</h2> </div>
role='main' can be used, the semantic <main> element is preferred for accessibility.<main> provides built-in semantic meaning and better support than a div with role.role='main' on a div instead of <main> -> Option B<aside> element is designed for complementary content like sidebars.<aside> already implies complementary role, so extra ARIA roles are unnecessary and may confuse screen readers.Pass the test and this pattern moves unknown