liveBook · Manning

Font-size property

As explained in Tiny CSS Projects

Text size is the typographic setting that determines the rendered dimensions of characters.

The CSS `font-size` property sets the size of text. Use it to make a heading prominent, distinguish a name from a job title, or give form labels less visual weight than the values people enter. section 6.7.1 section 10.5

You can set a size directly, as in `font-size: 27px` for credit-card numbers. Relative units are useful when text should scale with another size. `em` uses the parent element’s font size; `rem` uses the root (`html`) element’s font size. With the usual 16px browser default, `2rem` produces 32px. Relative sizes help text adapt to user settings and devices. section 9.4.3 section 6.7.1 section 4.1.1

Size a profile card

Give the name `font-size: 2rem` and the job title `font-size: 1.25rem`. The name stands out while the title remains easy to read. Adjusting their weight and color strengthens that distinction. section 6.7.1

Font size works alongside `font-family` and `line-height`. A display font’s glyphs may look smaller than another font’s at the same setting, so a drop cap can need `font-size: 6em`. Its larger size also makes its default line height tall; reducing `line-height` helps nearby text flow around the floated letter. Keep decorative fonts to short passages when readability matters. section 7.1.3

The `font` shorthand can set size with other typography choices: `font: 900 120px "Rubik", sans-serif` sets weight, size, and font family in one declaration. Check browser defaults, too: a form’s Send button may start with smaller text than the surrounding content, so `font-size: 1rem` brings it up to the intended size. section 5.3.1 section 10.7

Listing 6.11 Styling the name
h1 {                            #1
  font-size: 2rem;              #1
  margin: 36px 0 0;             #1
  color: var(--primary);        #1
}                               #1
 
.title {                        #2
  font-size: 1.25rem;           #2
  font-weight: bold;            #2
  color: var(--secondary);      #2
}                               #2

Compare the `rem` sizes used for the profile name and job title. section 6.7.1

How Tiny CSS Projects covers it

How deep it goes
Works through pixel, em, and rem values in CSS declarations, plus font shorthand and adjustments alongside line height.
Examples
Shows a profile name and job title at different sizes and an enlarged first letter beside flowing paragraph text.
What it assumes
Starts with HTML text elements and CSS rules while explaining em, rem, and the browser’s usual root-size default.
What you can do after
Apply it via CSS declarations to size interface text, choose relative units, and adjust oversized decorative letters.
How it connects
Connects font size to font family, font weight, line height, float, and accessible scaling.

Also explained in

Compare how 9 books explain font-size property →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Tiny CSS Projects. The section links point to the parts of the book it draws on.