MCQ Hive stays free thanks to ads. Please disable your ad blocker for this site so content and features keep working.
Web Development
CSS
Beginner
Q
If the root font size is 16px and a parent element has font-size: 20px, what are 2em and 2rem for a child's font-size?
A40px and 32px
BBoth 32px
CBoth 40px
D32px and 40px
Correct Answer:
A. 40px and 32px
Explanation:
em is relative to the parent's font size (for the font-size property). rem is relative to the root's font size.
ALSO KNOW (related points):
• What is the difference between :hover and ::before? → :hover is a pseudo-class (a state); ::before is a pseudo-element (generated content)
• What is the purpose of the srcset attribute on ? → It lets the browser choose an appropriately sized image for the screen's resolution and size