UNIT 20 • STAGE 2 OF 7

Mobile First

Learn to write mobile styles first, then enhance with min-width media queries , and build all 8 era entries

UNIT
STEP 1

Mobile First: Writing CSS in Reverse

Every media query you have written before this unit used max-width. That means you wrote desktop CSS first and then used max-width breakpoints to scale down for smaller screens. That is called desktop-first.

Mobile-first is the opposite: you write the default styles for small screens, then use min-width breakpoints to layer in enhancements for wider screens. The browser reads CSS top to bottom, so whatever is outside a media query is the base. Whatever is inside a min-width query only activates when the screen is wide enough.

// Desktop-first (what you have done before) .era-entry {
  flex-direction: row;  /* desktop layout as default */
}
@media (max-width: 768px) {
  .era-entry { flex-direction: column; }
}
// Mobile-first (what you will do in this unit) .era-entry {
  flex-direction: column;  /* mobile layout as default */
}
@media (min-width: 768px) {
  .era-entry { flex-direction: row; }
}

Both produce the same result. The difference is which is the starting point. Mobile-first is considered the better practice because most web traffic is on phones, so phones get the fastest, leanest CSS and wider screens get extras added on top.

The breakpoints for this unit

min-width: 768px, tablets and larger: era entries switch from stacked to side-by-side layout.
min-width: 1024px, desktops: wider padding, larger era numbers, more generous spacing.

STEP 2

Add the Series Intro

Between the hero and the era entries, add a brief framing paragraph. This is where students tell the reader what the series is, in their own words. The HTML is a section with a single paragraph. The CSS gives it a left-border accent and constrains its width.

// Series intro, left border accent, full width on mobile #series-intro {
  padding: 80px 32px 0;
  max-width: 900px;
  margin: 0 auto;
}
.intro-text {
  font-size: 1.0625rem;
  line-height: 1.85;
  color: var(--text-dim);
  border-left: 2px solid var(--gold-border);
  padding-left: 24px;
}
STEP 3

Build the Era Entries

The core of the homepage is a list of eight era entries. Each entry presents one research site. The design is an editorial stack: a numbered list where each entry has a large faded era number, the era name, year range, a student-written summary, and an "Explore the Record" link.

// Era entries section, max-width container with padding #era-entries {
  padding: 64px 32px 120px;
  max-width: 900px;
  margin: 0 auto;
}
// Each entry, mobile: stacked column / desktop: side-by-side row .era-entry {
  display: flex;
  flex-direction: column;  /* mobile: stacked */
  gap: 16px;
  padding: 48px 0;
  border-bottom: 1px solid var(--gold-border);
}
@media (min-width: 768px) {
  .era-entry {
    flex-direction: row;  /* tablet+: side by side */
    gap: 40px;
    align-items: flex-start;
    padding: 64px 0;
  }
}
// The era number, large Playfair, very faded, fixed width on desktop .era-number {
  font-family: 'Playfair Display', Georgia, serif;
  font-size: 4.5rem;  /* mobile: smaller */
  font-weight: 900;
  color: var(--text-light);
  opacity: 0.08;  /* very faded, decorative texture */
  line-height: 1;
  flex-shrink: 0;
  user-select: none;  /* not selectable, it is decoration */
}
@media (min-width: 768px) {
  .era-number {
    font-size: 7rem;  /* desktop: larger */
    width: 140px;  /* fixed column width */
    text-align: right;
    padding-top: 4px;
  }
}
// Era name, dates, summary, and explore link .era-content { flex: 1; }
.era-dates { font-size: 0.75rem; font-weight: 600; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-muted); margin-bottom: 10px; display: block; }
.era-name { font-family: 'Playfair Display', Georgia, serif; font-size: 1.75rem; font-weight: 700; line-height: 1.2; margin-bottom: 16px; }
.era-summary { font-size: 0.9375rem; line-height: 1.75; color: var(--text-dim); margin-bottom: 20px; }
.era-explore { display: inline-flex; align-items: center; gap: 8px; color: var(--gold-light); text-decoration: none; font-size: 0.875rem; font-weight: 600; letter-spacing: 0.04em; }
.era-explore:hover { color: var(--text-light); }

Write a 1 to 2 sentence summary for each era in the placeholder comment. What is the core story of that era? What was the defining law or event? These are your words, based on your eight research sites. The reading experience should feel like a guide written by someone who actually did the research, because you did.

Stage 2 Complete!

The homepage is taking shape: hero, framing paragraph, and all eight era entries. Stage 3 introduces clamp(), fluid type that scales smoothly between mobile and desktop without needing separate font-size declarations in every media query.

Code Editor
Live Preview