Web TechnologiesCourse and practice

Type and colour

The words for the letters and the colours of a page, from typeface and line height to palette and contrast, and how to use them to say why a page is hard to read or off-brand.

6 parts · about 12 min · taught in S4

Present Cheat sheet

Typefaces and fonts

Open Le Monde, then Doctolib. Le Monde's headlines have small strokes at the ends of the letters, like a printed newspaper. Doctolib's letters have plain ends. These are the two large groups of typefaces. A serif typeface has small strokes, called serifs, at the ends of its letters. It looks classic, literary or serious. A sans-serif typeface has none. It looks plain and modern, and it stays clear on small screens. Two more groups are useful to know. A monospace typeface gives every letter the same width, like a typewriter or a code editor. A display typeface is made for large titles only, such as a festival poster. In a paragraph, it becomes hard to read.

The diagram names the parts of a letter. The letters sit on a line called the baseline. The x-height is the height of the small letters, such as a and e. An ascender is the part of a letter above the x-height, as in f or d. A descender is the part below the baseline, as in p and y.

A typeface is the whole family of letters, such as Helvetica or Garamond. A font is one member of the family: one weight and one style, such as Garamond Bold Italic. Many people use the two words for the same thing, and designers understand both.

System fonts are the typefaces already installed on the visitor's phone or computer. They load instantly, but they look a little different on an iPhone and on Android. Web fonts are downloaded with the page, often from Google Fonts, a free library of more than a thousand typefaces. Every visitor then sees the same letters. Each extra web font makes the page slower to load.

Most good sites use one or two typefaces. Pairing means choosing two that work well together, often a serif for the titles and a sans-serif for the text. AI design tools tend to put the same plain sans-serif everywhere. It's never wrong, and it makes every portfolio look the same. A typeface also gives a tone: a law firm and a children's festival need different ones.

The example below shows the same project description twice. On the left, it's in a serif typeface. On the right, it's in a sans-serif. Look at the ends of the letters, and at the feeling each version gives. Then, in the code on the left, replace Georgia, serif with monospace to see a third family.

The parts of the letters, shown on one word: the baseline, the x-height, an ascender, a descender and a serif1. Baseline: The line that the letters sit on. 2. x-height: The height of the small letters, such as a, c and e. 3. Ascender: The part of a letter above the x-height, as in f. 4. Descender: The part of a letter below the baseline, as in p and y. 5. Serif: A small stroke at the end of a letter.1BaselineThe line that the letters sit on2x-heightThe height of the small letters,such as a, c and e3AscenderThe part of a letter above thex-height, as in f4DescenderThe part of a letter below thebaseline, as in p and y5SerifA small stroke at the end ofa letter

Swipe sideways to see the whole figure.

Figure 1

A serif typeface

Code
HTML
CSS
Result

A sans-serif typeface

Code
HTML
CSS
Result
The style rules both versions share
.ex-page { padding: 16px 20px; color: #18181b; }
h3 { margin: 0 0 8px; font-size: 26px; font-weight: 700; }
p { margin: 0; font-size: 18px; line-height: 1.5; }
Example 1The same project in a serif typeface and in a sans-serif typeface

Cheat sheet

Typefacepolice de caractères
a family of letters drawn in one style, such as Helvetica or Garamond.
Fontfonte
one member of a typeface, in one weight and one style, such as Garamond Bold Italic.
Serifavec empattements
describes a typeface whose letters end in small strokes, such as Times or Garamond.
Sans-serifsans empattements, linéale
describes a typeface whose letters have plain ends, such as Arial or Helvetica.
Monospacechasse fixe
describes a typeface where every letter has the same width, like a typewriter.
Display typefacepolice de titrage
a typeface drawn for large titles and posters, too decorative for a paragraph.
System fontpolice système
a typeface already installed on the visitor's device, which the page can use without downloading it.
Web fontpolice web
a typeface downloaded with the page, often from Google Fonts, so every visitor sees the same letters.
Pairingassociation de polices
two typefaces chosen to work together, often one for the titles and one for the text.

Size, weight and the type scale

Look at an article on Le Monde. The headline is large and bold. The introduction is a little smaller. The body text, the main text of the article, is smaller again, in a regular weight. The captions under the photos are the smallest. You know at once what to read first. This is typographic hierarchy: the order of importance that the type shows.

Designers create it with a type scale, a short list of text sizes where each size has a job. On your portfolio, the jobs could be your name, the section titles, the project titles, the body text, and small text such as captions. Sizes are given in pixels, or in rem, a unit that follows the reader's own text size setting. On a screen, body text is rarely smaller than 16 pixels.

Weight is the thickness of the letters. The usual names, from thin to thick, are light, regular, medium, semibold and bold. Italic is the sloping style, used to stress a word or for the title of a book. Two or three weights are enough. When everything is bold, nothing stands out.

Two typefaces at the same size can look very different in size. The reason is the x-height, the height of the small letters such as x, a and e. A typeface with a large x-height stays readable at small sizes, which matters for captions and on phones.

A pull quote is a short sentence taken from the text and shown in large type, to catch the eye. On a project page, it could be one sentence from your client or your tutor.

The example below shows the same top of a portfolio twice. On the left, every line has the same size and the same weight. On the right, the lines follow a type scale. Compare what you read first in each version. Then, in the code on the right, change the size of the name from 32px to 44px.

One size and one weight for everything

Code
HTML
CSS
Result

A type scale: each size has a job

Code
HTML
CSS
Result
The style rules both versions share
.ex-page { padding: 16px 20px; color: #18181b; }
h1, h2, h3, p, small { display: block; margin: 0 0 6px; line-height: 1.3; }
h2 { margin-top: 18px; }
Example 2The top of a portfolio with one size for everything, then with a type scale

Cheat sheet

Font sizecorps, taille de police
the size of the letters, given in pixels or in rem.
Weightgraisse
the thickness of the letters, named from light, regular and medium to semibold and bold.
Italicitalique
the sloping style of a typeface, used to stress a word or for the title of a work.
X-heighthauteur d'x
the height of the small letters such as x; a large x-height stays readable at small sizes.
Type scaleéchelle typographique
a short list of text sizes, each with a job, such as name, section title, body text and caption.
Typographic hierarchyhiérarchie typographique
the order of importance that sizes and weights give to the texts of a page.
Headlinetitre, gros titre
the large title at the top of a page or an article.
Body texttexte courant
the main text of a page, set in the size made for long reading.
Captionlégende
the short text that goes with a photo or a figure and says what it shows.
Pull quotecitation en exergue
a short sentence from the text, repeated in large type to catch the eye.

Line height, line length and alignment

Paragraphs need space in two directions. Line height, also called leading, is the distance from one line to the next. Designers often give it as a number: 1.5 means one and a half times the size of the letters. Body text usually needs between 1.4 and 1.6. When the lines are too tight, they seem to touch, and the eye slips to the wrong line. Large titles can have tighter lines.

Line length, also called the measure, is the number of characters in one line. About 60 to 75 characters is comfortable. On a wide screen, text that runs across the whole page makes lines of 150 characters or more. At the end of each line, the eye must travel back across the screen to find the start of the next one. It gets lost, and the reader gets tired. The fix is a maximum width for the text, even when the page is wider.

Letter spacing, also called tracking, is the space between all the letters of a word or a line. Kerning is the space between two particular letters, such as A and V, adjusted so that a word looks even. Bad kerning is most visible in large titles and logos.

Alignment says where the lines start and end. Left-aligned text starts every line at the same edge and leaves the right edge uneven, which is called ragged right. It's the easiest to read on a screen. Centred text suits a short title or a button. In a long paragraph, each line starts in a different place, and the eye has to search for it. Justified text fills each line from edge to edge, like a newspaper column. On the web, the browser stretches the spaces to do this, and white gaps can line up from one line to the next. These gaps are called rivers. A widow is the last line of a paragraph left alone at the top of a new column, and an orphan is the first line left alone at the bottom of one. On the web, people also say "widow" for one word alone on the last line of a title.

The example below shows two paragraphs. The first one runs across the whole width of the result, with tight lines. On a laptop, its lines hold well over 100 characters. The second one stops at about 65 characters per line, with more space between the lines. Read a few lines of each. Then, in the code, give the first paragraph max-width: 65ch (65 characters wide), or change its line height to 1.6.

The first paragraph is long and tight, the second is short and comfortable

Code
HTML
CSS
Result
The style rules it uses
.ex-page { padding: 16px 20px; color: #27272a; }
p { margin: 0 0 20px; font-size: 16px; }
Example 3Long lines packed tight, then short lines with more space between them

Cheat sheet

Line height or leadinginterlignage
the distance from one line of text to the next, often 1.4 to 1.6 times the size of the letters.
Letter spacing or trackingapproche
the space between all the letters of a word or a line.
Kerningcrénage
the space between two particular letters, such as A and V, adjusted so that the word looks even.
Line length or measurelongueur de ligne
the number of characters in one line of text, best at about 60 to 75.
Text alignmentalignement du texte
where the lines of a paragraph start and end: on the left, centred, on the right or justified.
Ragged rightfer à gauche, drapeau
text aligned on the left, with an uneven right edge.
Justified texttexte justifié
text stretched so that every line touches both edges, like a newspaper column.
Riverlézarde
a line of white gaps running down through justified text, made by stretched spaces.
Widowveuve
the last line of a paragraph left alone at the top of a column, or one word alone on a title's last line.
Orphanorpheline
the first line of a paragraph left alone at the bottom of a column or a page.

Palette and colour roles

Look at SNCF Connect. Almost everything is white, grey or dark blue. A few elements have a bright colour, and these are the ones you can act on. Error messages are red, and confirmations are green. That's a palette with roles. The palette is the short list of colours a site uses. A role is the job each colour does.

The brand colours come from the organisation's identity: its logo, its shop signs and its printed documents. The primary colour is the main one. It goes on the main buttons, the links and sometimes the header. A secondary colour is a second brand colour, used less often, for example in illustrations. The accent colour is a bright colour used in a few places only, to draw the eye, such as a "New" label.

Neutrals are the greys, from almost white to almost black. They do most of the work. The background is the colour behind the whole page. Surfaces are the colours of the boxes laid on it, such as cards and panels. The text colour is usually a very dark grey, which is softer for the eyes than pure black.

Semantic colours carry a meaning that visitors already know: green for success, orange for a warning, red for an error or a dangerous action, and blue for information. Keep them for these meanings. A red "Buy" button can look like a warning.

For your portfolio, a white background, light grey cards, dark grey text, one primary colour for links and buttons, and red for the form's errors are often enough.

The example below shows a small palette, with the role of each colour, and a project card that uses it. At the top of the code, each colour is named once, by its role. Try changing the value of --primary to #047857, a green: the button and the swatch change together.

Five colours, each with one role

Code
HTML
CSS
Result
The style rules it uses
.ex-page { padding: 16px 20px; }
.text { background: var(--text); }
.error { background: var(--error); }
h3, p { color: var(--text); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 16px; }
.swatches span { width: 92px; padding: 30px 8px 6px; border-radius: 8px;
  color: #fff; font-size: 13px; font-weight: 600; }
.swatches .accent, .swatches .surface { color: #18181b; }
.swatches .surface { box-shadow: inset 0 0 0 1px #d4d4d8; }
.card { max-width: 340px; padding: 16px; border-radius: 10px; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px;
  font-size: 12px; font-weight: 700; color: #18181b; }
.card h3 { margin: 10px 0 12px; font-size: 18px; }
button { border: 0; border-radius: 8px; padding: 9px 14px; color: #fff;
  font: 600 15px/1 Inter, Arial, sans-serif; }
.card .error-msg { margin: 10px 0 0; font-size: 14px; }
Example 4A small palette where each colour has a role, used on a project card

Cheat sheet

Palettepalette
the short list of colours that a site uses, each with its role.
Brand colourscouleurs de marque
the colours of an organisation's identity, taken from its logo and its documents.
Colour rolerôle de couleur
the job that a colour does on a page, such as text colour, link colour or error colour.
Primary colourcouleur principale
the main brand colour of a site, used for the main buttons and the links.
Secondary colourcouleur secondaire
a second brand colour, used less often than the primary colour.
Accent colourcouleur d'accent
a bright colour used in a few places only, to draw the eye.
Neutralsneutres, gris
the greys of a palette, from almost white to almost black, used for text, backgrounds and borders.
Backgroundfond, arrière-plan
the colour behind the whole page.
Surfacesurface
the colour of a box laid on the background, such as a card or a panel.
Semantic colourscouleurs sémantiques
colours with a fixed meaning: green for success, orange for a warning, red for an error.

Naming a colour, and contrast

Three words describe any colour. Hue is the colour itself: red, orange, blue or purple. Saturation is how strong it is, from grey to vivid. Lightness is how light or dark it is, from black to white. With these words, "make it more modern" becomes "the blue is too saturated, so it tires the eyes. Can we try a softer, greyer blue?"

A tint is a colour mixed with white, such as a pale blue for a background. A shade is a colour mixed with black, such as a dark blue for a button under the mouse. Warm colours, such as red, orange and yellow, feel close and full of energy. Cool colours, such as blue, green and purple, feel calm and distant. A monochrome design uses one hue in several tints and shades. A gradient is a smooth change from one colour to another. AI design tools often add purple and blue gradients, which is one reason their pages look alike. Opacity is how solid a colour is. At 50%, you see half of what's behind it.

Contrast is the difference in lightness between text and its background, measured as a ratio. A ratio of 1 to 1 means no difference, and black on white is 21 to 1. The accessibility rules, the international WCAG and the French RGAA, ask for at least 4.5 to 1 for body text. Large text and icons need at least 3 to 1. Light grey text on white, common in AI mockups, often fails. In the browser's developer tools, click a colour in the Styles panel to see its ratio.

Colour must never be the only signal. About one man in twelve has a form of colour blindness, often between red and green. For him, a field that only turns red when it's wrong shows nothing. Add a written message, or an icon.

The example below shows a short text and a form field with an error, twice. On the left, the text is light grey on white, with a ratio of 2.6 to 1, and only a red border shows the error. On the right, the text is dark grey, at 7.7 to 1, and a sentence explains the error. In the code on the left, try #71717a, a grey that just passes.

Pale text, and an error shown by colour alone

Code
HTML
CSS
Result

Dark text, and an error with a written message

Code
HTML
CSS
Result
The style rules both versions share
.ex-page { padding: 16px 20px; font-size: 16px; }
p { margin: 0 0 14px; }
label { display: grid; gap: 4px; font-size: 15px; }
input { width: 14em; max-width: 100%; padding: 7px 10px; font: inherit; color: #18181b;
  border: 2px solid #71717a; border-radius: 8px; }
.msg { margin: 6px 0 0; font-size: 15px; }
Example 5Text and an error that fail the contrast rules, then text and an error that pass

Cheat sheet

Hueteinte
the colour itself, such as red, blue or purple.
Saturationsaturation
how strong a colour is, from grey to vivid.
Lightnessluminosité
how light or dark a colour is, from black to white.
Tint and shadeteinte claire, teinte foncée
a colour mixed with white, and a colour mixed with black.
Warm and cool colourscouleurs chaudes et froides
reds, oranges and yellows feel warm; blues, greens and purples feel cool.
Monochromemonochrome
describes a design that uses one hue only, in several tints and shades.
Gradientdégradé
a smooth change from one colour to another across a surface.
Opacityopacité
how solid a colour is; at low opacity, you see what is behind it.
Contrast ratiorapport de contraste
a measure of the difference in brightness between text and its background, at least 4.5 to 1 for main text.
Colour blindnessdaltonisme
difficulty telling some colours apart, often red and green, which affects about one man in twelve.

How to say it

"I don't like it" and "make it pop" give a designer nothing to work on. An AI design tool such as Stitch answers them with a random change: more colour, a gradient, a bigger title. "Make the text darker" is more precise. However, it chooses the fix before naming the problem, and there may be a better fix.

Useful feedback has three parts: what you see, its effect on visitors, and what you want. Use the words of this lesson for the first part:

  • "The line height is too tight: the lines of the descriptions touch. Can we go to about 1.5?"
  • "The descriptions run across the whole screen, in lines of about 150 characters, so they're tiring to read. Could the text stop at about 70 characters per line?"
  • "The body text is light grey on white, with a contrast of 2.6 to 1. Older visitors will struggle to read it. It needs at least 4.5 to 1."
  • "The page uses three typefaces and five weights, so it looks busy. Can we keep one typeface for the titles and one for the text?"

Then sort your remarks before you send them. Blocking problems come first: text that people can't read, a button that nobody sees, an error shown only in red. Next comes what's off-brand, meaning it doesn't fit the image the site should give, such as a playful display typeface on a serious engineering profile. Matters of taste come last, such as "I'd prefer blue". Ten small remarks about shades of blue can hide the one blocking problem. If needed, send the blocking problems on their own.

AI design tools start from the same defaults: one plain sans-serif everywhere, purple and blue gradients, light grey text. "It looks like every AI site" becomes useful when you name the defaults you see. Then give your references: a mood board, or the organisation's style guide, the document that fixes its logo, typefaces and colours. Ask for the final colours and type sizes as design tokens, so that the coding agent reuses the same values. If the site gets a dark mode later, each colour role then only needs a second value. With Stitch, ask for one change at a time, and compare the result with what you asked for.

Cheat sheet

Feedbackretours
comments on a design, sent to the person or the tool that made it.
Blocking problemproblème bloquant
a problem that stops visitors, such as text they can't read or a button they can't find.
Off-brandhors charte
describes a design that doesn't fit the image an organisation wants to give.
Matter of tastequestion de goût
a personal preference, such as a favourite colour, which doesn't stop any visitor.
Defaultréglage par défaut
the choice a tool makes when nobody asks for anything else.
Mood boardplanche d'inspiration
one page of screenshots, photos, colours and fonts that shows the feeling a site should give.
Style guidecharte graphique
the document that fixes an organisation's logo, typefaces, colours and how to use them.
Design tokendesign token
a colour, font or spacing defined once under a name, such as "brand colour", which every style rule uses.
Dark modemode sombre
a second set of colours for a site, with dark backgrounds and light text.

Practise this strand

These questions put you in the situations this lesson describes. You answer in your own words, and you get a level, feedback and a full answer.