The selector span.highlight is the most performant because it directly targets elements by tag and class without complex ancestry or universal selectors.
Universal selector * matches all elements and is slow. Complex descendant selectors require more work.
Deeply nested and complex selectors force browsers to check many elements, slowing down rendering.
Semantic HTML, external CSS, and CSS variables do not inherently slow rendering.
Changing background-color only triggers repaint, not layout recalculation, so it is faster.
Changing width, margin, or font-size affects layout and triggers reflow, which is more expensive.
Using media queries to load simpler styles on small screens improves performance and keeps content accessible.
Removing focus styles hurts keyboard users. Low contrast hurts readability. Hiding content with display:none removes it from screen readers.
<p> text inside <div id="container"> have?div p { color: blue; }
#container p { color: red !important; }
p { color: green; }div p { color: blue; }
#container p { color: red !important; }
p { color: green; }The rule with !important always wins, so #container p { color: red !important; } sets the text color to red.
Other rules are overridden even if they have higher specificity or come later.