Performance: Heading classes
This affects page load speed and rendering performance by controlling how heading styles are applied and how many CSS rules the browser must process.
<h1 class="display-1">Title</h1> <h2 class="display-2">Subtitle</h2>
<h1 class="custom-large-heading custom-bold custom-color">Title</h1> <h2 class="custom-large-heading custom-bold custom-color">Subtitle</h2>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Multiple custom classes per heading | Low (few nodes) | Multiple reflows due to style recalculations | Medium paint cost | [X] Bad |
| Bootstrap heading classes (e.g., display-1) | Low (few nodes) | Single reflow per class application | Low paint cost | [OK] Good |
display-1 to display-4, where display-1 is the largest size.display-1 is the biggest heading style.h1 tag with Bootstrap display classesdisplay-4 thinking higher number means biggerlead which styles paragraphs, not headingsh2 element?display-1 to display-4 and must be added inside the class attribute.<h2 class='display-2'>Hello</h2> uses class='display-2' correctly. <h2 display-2>Hello</h2> misses class=. <h2 class='display2'>Hello</h2> uses wrong class name display2. <h2 class='display-5'>Hello</h2> uses invalid class display-5 which doesn't exist.<h3 class='display-3'>Title</h3> compared to <h3>Title</h3> in Bootstrap?h3 with display-3display-3 on h3 makes the text bigger and bolder than the normal h3 style.<h1 class='display-5'>Welcome</h1>display-1 to display-4. There is no display-5.h1 tag cannot have classes. is false because h1 can have classes. The class name should be display_5 with underscore. is incorrect because Bootstrap uses dashes, not underscores. The text 'Welcome' should be inside a span. is unnecessary; text can be directly inside h1.h4 for accessibility. Which is the best way to do this?h4) should reflect the document structure. Visual size can be changed with Bootstrap classes.<h4 class='display-1'>Big Heading</h4> keeps h4 semantic tag and applies display-1 for large style. <h1 class='display-4'>Big Heading</h1> uses h1 which changes semantics. <div class='display-1'>Big Heading</div> uses div which is not semantic heading. <h4 style='font-size: 3rem;'>Big Heading</h4> uses inline style, not Bootstrap class.Pass the test and this pattern moves unknown