Selectors & Text: Hero Title + Lead + Emphasis (Interview Warm-up)
Solution idea
Use element selectors to set the baseline rhythm across the hero (font size, line-height, margin, and color). Then apply class selectors for targeted emphasis like a muted tagline or a highlighted word. This demonstrates clean cascade usage, minimal specificity, and intentional visual hierarchy without over-nesting selectors or relying on ids.
Solution
Overview
Use element selectors to set the baseline rhythm across the hero (font size, line-height, margin, and color). Then apply class selectors for targeted emphasis like a muted tagline or a highlighted word. This demonstrates clean cascade usage, minimal specificity, and intentional visual hierarchy without over-nesting selectors or relying on ids.
Approach — Base Elements + Targeted Class Overrides
First, style h1 and p directly to create the default typography system: size, line height, spacing, and base color. Next, apply a .tagline class to soften contrast or weight for secondary copy so hierarchy is visible. Finally, wrap the emphasized word in a span with .highlight to raise contrast or weight. Keep selectors flat so later overrides remain predictable and maintainable.
<h1 class='headline'>
Welcome to CSS Basics
</h1>
<p class='tagline'>
CSS lets you style
<span class='highlight'>
text
</span>
, layouts, and more.
</p>h1 {
font-size: 2rem;
margin: 0;
color: #111;
}
p {
margin: 0.5rem 0 0;
line-height: 1.6;
color: #333;
}
.tagline {
color: #555;
}
.highlight {
color: #3b82f6;
font-weight: 600;
}Notes & Pitfalls
Only using classes and skipping element selectors defeats the point of the exercise. Forgetting to reset default margins often causes unexpected spacing in real UIs. If you style pcolor but never override.tagline, you miss the specificity/override practice.
Use element selectors for baseline typography and layout rhythm. Use classes for component-level overrides and emphasis. Keep overrides minimal so the cascade stays predictable.
Resources
Similar questions
Guides
Preparing for interviews? Use Frontend Coding Challenges first, then move into a concrete Study Plan before targeted Company Prep.
Built in public
The code behind FrontendAtlas lives on GitHub. A star helps other frontend engineers find it.