html {
font-size: 16px;
}
body {
font-size: 1.25rem;
}
p {
font-size: 120%;
}The root font size is 16px. The body font size is 1.25rem, which is 1.25 × 16px = 20px. The paragraph font size is 120% of the body font size, so 120% × 20px = 24px.
All options set the font size to 32px:
- 2rem = 2 × 16px = 32px
- 200% of base 16px = 32px
- 32px directly sets the size
Therefore, all options produce the same visual size.
Option C uses *= which matches if the style attribute contains the substring 'font-size: 1.5rem' anywhere, so it matches paragraphs with that font size even if other styles exist.
Option C requires the style attribute to be exactly 'font-size: 1.5rem', so it fails if other styles are present.
Options A and C match only if the style ends or starts exactly with that substring, which is less flexible.
Em units scale relative to the font size of the element or its parent. If the container's font size increases, items sized with em units inside it become larger.
Option A is incorrect because em units are not fixed to root font size (that's rem).
Options C and D are incorrect because increasing font size does not shrink or invalidate em units.
Using relative units like rem or em allows text to scale based on user preferences and browser settings, improving accessibility.
Fixed pixel sizes (option B) prevent scaling and can make text too small or too large for some users.
Very small font sizes (option B) reduce readability.
Using !important (option B) blocks user adjustments, harming accessibility.