Performance: Card structure (header, body, footer)
This affects page load speed and rendering performance by how many DOM elements and CSS styles are used in the card layout.
<div class="card"> <div class="card-header"> <h5>Title</h5> <small>Subtitle</small> </div> <div class="card-body"> <p>Some text content here.</p> <button type="button">Click me</button> </div> <div class="card-footer"> <small>Footer info</small> </div> </div>
<div class="card"> <div class="card-header"> <h5>Title</h5> <div><small>Subtitle</small></div> </div> <div class="card-body"> <p>Some text content here.</p> <div><button type="button">Click me</button></div> </div> <div class="card-footer"> <small>Footer info</small> </div> </div>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Nested divs inside card sections | High (many nodes) | Multiple reflows | High paint cost | [X] Bad |
| Flat structure with semantic Bootstrap classes | Low (fewer nodes) | Single reflow | Low paint cost | [OK] Good |
card-header is used to style the header section of a card.card-header -> Option Bcard-header [OK]card-header class [OK]card-title with headercard-topdiv with class card-body to hold the main content.<div class='card-body'>Content</div> uses <div class='card-body'>, which is the standard Bootstrap structure.div.card-body [OK]div with class card-body [OK]section or bodycard-content<div class='card'> <div class='card-footer'>Footer</div> <div class='card-header'>Header</div> <div class='card-body'>Body</div> </div>
<div class='card'> <div class='card-header'>Title</div> <div class='card-body'>Content</div> <div class='card-footer'>Footer</div> </div>
div has class card, which is correct.div.card [OK]card-footer for footer sectioncard-footer class to style it as a card footer.d-flex makes the footer a flex container, and justify-content-end pushes content to the right.card-footer d-flex justify-content-end -> Option Ad-flex justify-content-end [OK]float-right classtext-center which centers contentalign-items-start which aligns verticallyPass the test and this pattern moves unknown