Using Relative Units in CSS for Responsive Text
📖 Scenario: You are creating a simple webpage that needs to have text that adjusts size based on the user's device or browser settings. This helps make your page easier to read on phones, tablets, and desktops.
🎯 Goal: Build a webpage with a heading and paragraph where the font sizes use relative units rem and em so the text scales nicely on different screen sizes.
📋 What You'll Learn
Use
rem units for the heading font sizeUse
em units for the paragraph font sizeSet the root font size in the
html selectorInclude a
<header> with a heading and a <main> with a paragraphMake sure the CSS uses relative units only for font sizes
💡 Why This Matters
🌍 Real World
Websites need to be readable on many devices. Using relative units like <code>rem</code> and <code>em</code> helps text scale properly for phones, tablets, and desktops.
💼 Career
Front-end developers use relative units to create accessible and responsive designs that adapt to user preferences and device sizes.
Progress0 / 4 steps