Skip to main content
Section 2

Design and build the frontend

A UI that is fast, accessible, and looks intentional.

4 lessons25-question quiz
2.1

Giving it a design language

7 min read

Two products can use the same colors and the same font and still feel completely different: one looks intentional, the other looks assembled from spare parts. The difference is usually not talent. It is whether a small, consistent set of choices, type, color, spacing, and reused components, gets defined once and actually reused everywhere, instead of re-decided on every screen.

The four things to lock down early

ElementDefine onceWhy it holds together
TypeOne or two font families, a short scale of sizes and weights for headings and body textA predictable hierarchy is easier to scan and easier to build with
ColorA small palette: background, text, one or two accents, plus their states (hover, disabled)Fewer color decisions per screen means faster, more consistent choices
SpacingOne spacing scale (for example 4, 8, 16, 24, 32, 48px) used for every gap and paddingConsistent spacing is what makes related elements read as a group
ComponentsA button, a card, an input, a nav item, each built once and reusedEvery reuse reinforces the pattern instead of introducing a new one
A minimal design language

None of this is arbitrary. It maps onto the findings in the core laws of UX and UI design: a short, chunked type scale respects the same limited working memory behind Miller's Law, a small reused color and spacing system is what lets Gestalt grouping read correctly, and following the visual conventions people already know from other products is Jakob's Law in practice. This lesson is the practical version of that guide: what to define before you lay out a single screen.

How to apply it

  • Write the type scale and spacing scale down before building any layout. A short list of allowed values is easier to hold to than "whatever looks right" in the moment.
  • Pick a base spacing unit and only use multiples of it. Arbitrary pixel values are how spacing quietly drifts screen by screen.
  • Build shared components, a button, a card, an input, once, and change them in one place instead of copying and tweaking markup for each new screen.
  • Before adding a new color, font size, or one-off spacing value, check whether an existing one already does the job.
Key idea
A design language is not decoration. It is a small, written set of choices for type, color, spacing, and components, reused everywhere instead of re-invented per screen. That repetition is what reads as designed rather than assembled.
Key terms
Design language
The small, reused set of type, color, spacing, and component choices that give a product a consistent look.
Spacing scale
A short list of allowed spacing values (for example 4, 8, 16, 24px) used everywhere instead of arbitrary pixel values.
2.2

Responsive and mobile-first

7 min read

A responsive layout is one codebase that rearranges itself to fit whatever screen it is shown on, instead of a separate design for every device. Getting that right starts with which end you design from first.

Start from the smallest screen

Mobile-first design means building the layout for the narrowest, most constrained screen first, then adding complexity as more space becomes available, rather than designing a wide desktop layout and squeezing it down afterward. Starting narrow forces real priority decisions early: what actually has to be on screen, and what can wait. Starting wide and shrinking tends to produce a desktop layout with things quietly hidden or crammed together on a phone.

Breakpoints

A breakpoint is a screen width where the layout changes to fit the available space better. You do not need one for every possible screen size, only for the handful of widths where the current layout stops working well.

RangeTypical deviceWhat usually changes
Up to about 640pxPhoneSingle column, stacked navigation, full-width buttons, larger tap targets
About 640 to 1024pxTablet, small laptopTwo-column sections start to appear, navigation may still be collapsed
1024px and upLaptop, desktopFull multi-column layout, navigation fully visible, more content per view
A common three-tier breakpoint pattern

Search engines see the mobile version

This is not only about how the site looks on a phone. Google, the dominant search engine, indexes and ranks pages using the mobile version of the content, not the desktop version, for the large majority of sites. A layout that hides content, breaks navigation, or drops text on small screens is not just a worse mobile experience. It is the version search engines are actually evaluating.

Check real breakpoints on a real device or a device emulator, not just by dragging a desktop browser window narrower. A resized browser window still has a mouse cursor and no touch targets; a phone does not.
Key idea
Design for the small screen first, add layout as space allows at a small number of breakpoints, and remember the mobile layout is usually what search engines index, not a mobile-only afterthought.
Key terms
Responsive design
A layout that adapts to the screen it is shown on, using one codebase.
Breakpoint
A screen width where the layout changes to better fit the available space.
Mobile-first indexing
A search engine practice of using a page's mobile version, not its desktop version, to index and rank it.
2.3

Accessibility, not optional

7 min read

Accessibility is not a feature added at the end. It is whether the people who navigate by keyboard, by screen reader, or with limited vision can actually use what you built. A surprising amount of it comes from a short list of habits applied consistently, not a specialized skill learned separately.

Semantic HTML

Use the HTML element built for the job: a real <button> for something clickable, a real <nav> for navigation, an ordered sequence of heading levels, <h1> through <h6>, instead of styled <div> elements with a click handler. Screen readers and keyboard navigation are built to understand these real elements. A <div> styled to look like a button gives a mouse user something clickable and gives a keyboard or screen reader user nothing at all.

The essentials

  • Keyboard operability: every interactive element must be reachable and usable with Tab, Enter, and Space alone, with a visible focus outline, not just a mouse hover state.
  • Real labels: every form input needs a linked <label>, and every icon-only button needs an accessible name, such as an aria-label, when there is no visible text.
  • Alt text: every meaningful image needs a written description in its alt attribute; a purely decorative image gets an empty alt so screen readers skip it instead of reading a meaningless filename.
  • Color contrast: WCAG AA requires at least 4.5:1 contrast between text and its background for normal text, and at least 3:1 for large text (roughly 18pt, or 14pt bold, and up).

Contrast is easy to get wrong by eye: light gray text on a white background often looks fine to a designer with good vision and fails the 4.5:1 ratio outright. Run actual text and background colors through a contrast checker rather than judging by eye, especially for body copy, form labels, and any text placed over an image.

Key idea
Semantic elements, full keyboard operability, real labels and alt text, and 4.5:1 (3:1 for large text) color contrast cover most of what makes an interface usable by everyone, not just people using a mouse with typical vision.
Semantic HTML is also what search engines parse to understand a page's structure, so building it correctly for accessibility tends to help search visibility at the same time, not trade off against it.
Key terms
WCAG
Web Content Accessibility Guidelines, the standard reference for what makes a site accessible.
More

WCAG defines conformance levels A, AA, and AAA. AA is the commonly required bar, including the 4.5:1 text contrast minimum.

Alt text
A written description of an image, read aloud by screen readers in place of the image itself.
Focus indicator
The visible outline or highlight shown around the element currently selected by keyboard navigation.
2.4

Frontend performance

7 min read

A slow interface is not an abstract problem. It is felt directly, as a wait before something useful appears or a tap that does not seem to register. Core Web Vitals are a small set of metrics built to measure that felt experience in concrete numbers, rather than leaving "fast enough" to guesswork.

The three Core Web Vitals

MetricWhat it measuresGood threshold
LCP (Largest Contentful Paint)How long the largest visible element takes to render2.5 seconds or less
INP (Interaction to Next Paint)How quickly the page visibly responds after a click or tap200 milliseconds or less
CLS (Cumulative Layout Shift)How much visible content unexpectedly shifts position while loadingA score of 0.1 or less
What each metric measures, and what "good" looks like
INP replaced an older metric called First Input Delay as the official responsiveness measure in 2024. The difference matters: First Input Delay only timed the first interaction, while INP looks at responsiveness across the whole visit.

What actually moves those numbers

  • Image optimization: serve images sized for where they are shown, use a modern compressed format, and compress before upload. Images are usually the single heaviest thing on a page, and often the element LCP is timing.
  • Lazy loading: load offscreen images and non-critical content only as the user scrolls near them, so the initial page load is not paying for content nobody has reached yet.
  • Keep the JavaScript bundle small: every kilobyte of JS has to be downloaded, parsed, and run before the page is fully interactive. Ship only what the current page needs, and load rarely used, heavy features only when they are actually used.

Reserve space for images and embedded content with explicit dimensions so the browser does not have to shift the layout once they finish loading. That single habit accounts for a large share of avoidable CLS.

Key idea
Core Web Vitals turn "feels slow" into a number you can act on. The biggest wins are usually unglamorous: smaller and better-timed images, and less JavaScript shipped than the page actually needs.
Key terms
Core Web Vitals
A set of user-facing performance metrics: LCP, INP, and CLS.
Lazy loading
Delaying the load of offscreen content until the user scrolls near it.
Layout shift
When visible content moves position unexpectedly as a page finishes loading.

Section 2 quiz

25 questions. Pass at 75% to master this section. Retakes are unlimited, and the quiz is where the learning sticks.

Section 2 quiz · Design and build the frontendQuestion 1 of 25

According to the lesson, which four elements make up a minimal design language?