Typography, Color, Responsive Grids and Anti-Slop Craft
You can multiply a type scale from an 18px body size, cap a paragraph between 60 and 75ch, divide a contrast ratio from two luminances, and check one page for overflow and landmarks at 320px and 1440px.
- Level
- Navigator
- Time
- 22 h

Jump to
After this course you can
The student can code a responsive multi-page HTML/CSS layout that meets exact contrast ratios, line-length bounds, semantic landmark rules, and zero horizontal overflow across 6 viewport widths.
Multiply a type scale
A type scale is a short list of sizes from one body size and one ratio. This lesson uses 18px for body text and the ratio 1.25. Multiply the exact previous size by 1.25, then round that product to the nearest pixel for the CSS rule. The next multiplication uses the exact product, so a rounded pixel stays in the stylesheet. When the fraction is exactly 0.5, round away from zero.
Start at 18. Then 18 × 1.25 = 22.5, and the CSS size is 23px, used for a card title. Then 22.5 × 1.25 = 28.125, which rounds to 28px for a section heading. Then 28.125 × 1.25 = 35.15625, which rounds to 35px, kept for a figure the reader must see first, such as a clock time. Then 35.15625 × 1.25 = 43.9453125, which rounds to 44px for the page title. The five CSS sizes are 18, 23, 28, 35, and 44. Body line-height is 1.5, so 18 × 1.5 = 27px between baselines. The title uses 1.2, so 44 × 1.2 = 52.8, which rounds to 53px.
Count the line in ch
The ch unit is the advance width of the glyph 0 in the font that draws the element. A rule of max-width: 65ch makes the line 65 zeros wide at any pixel size. A long line makes the eye lose the start of the next line. A very short line forces a new jump every few words. Keep the paragraph max-width from 60ch to 75ch. When the screen is narrower than that cap, the line becomes as wide as the content box, and the page still has no horizontal scroll. A count of letters on the same line can sit a little lower or higher, because most letters differ in width from the zero. The CSS cap is the check.
In this lesson's example font the zero is half an em. At 18px, 1ch is 9px. Then 60ch is 540px, 65ch is 585px, and 75ch is 675px. A grid of 1040px holds 1040 / 9 = 115.6ch, past 75. The cards may use the 1040px grid. The paragraph inside a card still carries max-width: 65ch, so on a wide viewport the line stops at 585px. At a 390px viewport with 16px of padding on each side, the inner width is 390 − 32 = 358px. Then 358 / 9 = 39.8ch. That line is under 60ch because the screen is narrow. At 1440px, confirm the paragraph stops on the 65ch cap. At 390px, confirm the same paragraph stays inside the screen.
Contrast from luminance
Ordinary text needs a contrast ratio of at least 4.5 to 1. Large text means 24px or larger, or bold text at weight 700 or higher and 18.66px (14pt) or larger, and that large text may use 3 to 1. The ratio uses relative luminance. Take each sRGB channel as a number from 0 to 1. When the channel is at most 0.04045, divide it by 12.92. Otherwise add 0.055, divide by 1.055, and raise the result to the power 2.4. Luminance L is 0.2126R + 0.7152G + 0.0722B. The contrast ratio is the lighter luminance plus 0.05, divided by the darker luminance plus 0.05.
Gray #767676 on white is the worked sample, because the three channels match and the ratio sits close to 4.5. Divide 118 by 255 to get 0.462745. Add 0.055 to get 0.517745, then divide by 1.055 to get 0.490754. A calculator gives 0.490754 to the power 2.4 as 0.181164, which rounds to 0.1812. Equal channels mean the luminance is 0.1812. White has luminance 1. Then (1 + 0.05) / (0.1812 + 0.05) = 1.05 / 0.2312 = 4.54. The pair meets 4.5 to 1 for ordinary text, with little room left. Recompute a page color when you change one hex step, because that step can drop the ratio under 4.5.
Grid, landmarks, and the first sentence
The sample page lists free desks on Tuesday. From 1040px upward the content frame is 1040px wide, centered with margin-left and margin-right set to auto. CSS Grid draws twelve 1fr tracks and a 16px column gap. Eleven gaps are 11 × 16 = 176, so the tracks share 1040 − 176 = 864, and 864 / 12 = 72px each. Four cards each span three tracks. One card is 3 × 72 + 2 × 16 = 248px. Four cards and the three gaps between them are 4 × 248 + 3 × 16 = 1040. At 1440px the free space is 1440 − 1040 = 400, so 200px sits on each side. At 1920px the frame stays 1040px and each side is (1920 − 1040) / 2 = 440px. At 1024px a 1040px frame would spill, so the frame becomes width 100% with 32px padding. The inner width is 1024 − 64 = 960, and two cards split it as (960 − 16) / 2 = 472px. At 768px the padding is 24px, the inner width is 720px, and two cards are (720 − 16) / 2 = 352px. At 390px and at 320px the padding is 16px, the inner widths are 358px and 288px, and the cards stack in one column.
Two overflows are easy to count. A picture with width 400px inside the 358px card sticks out by 400 − 358 = 42px at 390px, and by 400 − 288 = 112px at 320px. Set max-width: 100% and height: auto on the picture, and set box-sizing: border-box on every element so padding counts inside the width. Four links in a Flexbox row, with flex-wrap left at nowrap and a min-width of 120px, need 4 × 120 = 480px. Against 358px they stick out by 122px. Set flex-wrap: wrap. The page has one header, one nav, one main, and one footer. Those four elements are the landmarks. The booking facts live in main, under a single h1, Tuesday desks. The first sentence in main reads: Four desks are free on Tuesday. Each booking holds the desk for 30 minutes. A row of cards that only says Fast, Simple, and Secure gives the reader no desk, no clock time, and no duration. Each card here names a desk, a clock time, and the 30-minute hold. A button reads Book desk 14.
The Tuesday page, counted through
Body text is 18px and the ratio is 1.25. The CSS sizes beside 18 are 23, 28, 35, and 44. The title Tuesday desks is 44px on a 53px line box. Card titles are 23px. Section headings are 28px. The clock time on a card uses the 35px step.
The example font has a zero of half an em, so at 18px one ch is 9px. The paragraph max-width is 65ch, which is 585px. At 1440px the grid is 1040px, and 1040 / 9 = 115.6ch, so the cap is what keeps the line inside 75ch. At 390px the inner width is 358px, about 39.8ch, and the line stays on screen.
Paper #F7F4EF has linear channels 0.9301, 0.9047, and 0.8632. Then 0.2126 × 0.9301 = 0.1977, 0.7152 × 0.9047 = 0.6470, and 0.0722 × 0.8632 = 0.0623. Those rounded products add to 0.9070, and the unrounded sum used below is 0.9071. Ink #1A1A1A has luminance 0.0103. The ratio is (0.9071 + 0.05) / (0.0103 + 0.05) = 0.9571 / 0.0603 = 15.87. Muted #7A756C has linear channels 0.1946, 0.1779, and 0.1500. Then 0.2126 × 0.1946 = 0.0414, 0.7152 × 0.1779 = 0.1272, and 0.0722 × 0.1500 = 0.0108, which add to 0.1794. The ratio is 0.9571 / 0.2294 = 4.17, under 4.5, so that gray stays off body text. Replacement #6B675F has linear channels 0.1470, 0.1356, and 0.1144. Then 0.2126 × 0.1470 = 0.03125, 0.7152 × 0.1356 = 0.09698, and 0.0722 × 0.1144 = 0.00826. Those add to 0.13649, which rounds to 0.1365. The ratio is 0.9571 / 0.1865 = 5.13, which clears 4.5. Body text uses #6B675F on #F7F4EF.
Landmarks in source order are header, nav, main, and footer. The h1 sits in main once. At 320px the inner width is 288px, so the 400px picture would overflow by 112px until max-width: 100% is set. The four links wrap. The first sentence keeps the four desks and the 30 minutes.
Check it on paper
Use a body size of 16px and the ratio 1.25. Multiply the exact value each time, and write the CSS pixel after rounding to the nearest pixel, with a tie of 0.5 rounded away from zero. You should get 16, then 20, then 25, then 31, then 39. In the example font the zero is half an em, so at 16px one ch is 8px. Write 70ch in pixels, and write how many ch a 960px column is. Then take luminance 0.1365 for the text and 0.9071 for the paper. Divide (0.9071 + 0.05) by (0.1365 + 0.05) and round to two decimals. Last, a 320px viewport with 16px padding on each side holds a picture of 400px. Write the overflow in pixels.
The sizes are 16, 20, 25, 31, and 39, from the exact products 20, 25, 31.25, and 39.0625. Then 70ch is 560px. A 960px column is 960 / 8 = 120ch, past 75, so the paragraph still needs a ch cap. The contrast ratio is 5.13. The inner width is 320 − 32 = 288px, and the picture overflows by 400 − 288 = 112px.
Check questions
On the 18px scale with ratio 1.25, what CSS pixel size is the page title, the step whose exact product is 43.9453125?
44px. The product 43.9453125 rounds to 44, and a tie of 0.5 would round away from zero, as 22.5 already did on the way to 23.
In the example font at 18px, how many pixels is 65ch, and how many ch is the 1040px grid?
585px, and 115.6ch. The paragraph cap stays at 65ch so the line stops at 585px.
With luminances 0.1812 and 1, what contrast does #767676 on white give, rounded to two decimals, and does that pair meet 4.5 to 1?
4.54, from 1.05 / 0.2312. The pair meets 4.5 to 1 for ordinary text.
By how many pixels do four nowrap links of min-width 120px overflow a 358px row, and which landmark holds the sentence about the four desks?
122px, because 480 − 358 = 122. The sentence sits in main.
A page you can check by hand has sizes from one multiplied ratio, a paragraph cap from 60ch to 75ch, a text-to-paper ratio of at least 4.5, and a frame that stays inside the viewport from 320px to 1920px with a single main and a first sentence that states the count.
Final task
Submit a responsive HTML/CSS codebase verified by automated Playwright and CSS computed-style tests across 320px, 390px, 768px, 1024px, 1440px, and 1920px viewports (checking contrast ≥ 4.5:1, 60–75ch measure, and zero overflow). (Optional Portfolio item: visual design showcase).
Terms in this course
This course has no terms of its own in the glossary yet. Terms from earlier courses are used here too.
The first lesson is open to read. The rest of the course is being written, and tests and diplomas come later. Join the waitlist