Performance: Color utilities (text, background)
This affects page rendering speed and visual stability by controlling how colors are applied and repainted on the page.
<div class="text-danger bg-warning">Hello</div>
<div style="color: red; background-color: yellow;">Hello</div>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Inline styles for colors | None | 0 | High (many repaints if used often) | [X] Bad |
| Bootstrap color utility classes | None | 0 | Low (cached styles, minimal repaint) | [OK] Good |
text-{color} classes to change text color, where {color} is a predefined color name.text-danger applies a red color to text. The other options either apply background color or use incorrect class names.bg-{color} classes to set background colors, where {color} is a predefined color name.bg-primary sets a blue background. The other options either set text color or use invalid class names.<p class="text-success">Success message</p>
text-success is used on the paragraph tag.text-success applies a green color to the text.bg-warningg. What will happen?bg-warning, but bg-warningg has an extra 'g' and is invalid.bg-danger sets a red background color in Bootstrap.text-white sets the text color to white.btn bg-danger text-white applies a red background and white text on the button.Pass the test and this pattern moves unknown