Performance: HTML document structure
This affects the browser's ability to start rendering the page quickly and correctly by defining the critical rendering path.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Page Title</title> </head> <body> <div>Content</div> </body> </html>
<html><body><div>Content</div></body></html>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Missing DOCTYPE and <head> | Minimal but causes quirks mode | Multiple reflows due to layout recalculations | Higher paint cost due to unstable layout | [X] Bad |
| Complete HTML structure with DOCTYPE and <head> | Standard DOM tree | Single reflow on initial layout | Lower paint cost with stable layout | [OK] Good |
<!DOCTYPE html> with uppercase DOCTYPE and lowercase html.<!DOCTYPE html> <html> <head> <title>Test Page</title> </head> <body> <h1>Hello</h1> <p>Welcome to the page.</p> </body> </html>
<!DOCTYPE html> <html> <head> <title>Page</title> <body> <h1>Welcome</h1> </body> </html>
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>My Page</title> </head> <body> <header>Site Header</header> <main>Main content here</main> <footer>Site Footer</footer> </body> </html>correctly places <header>, <main>, and <footer> inside <body> and includes meta charset and lang attribute.
Pass the test and this pattern moves unknown