liveBook · Manning

Font-size property

As explained in Web Design Playground, Second Edition

The CSS font-size property specifies the size of text rendered for an element.

The CSS font-size property controls how large text appears inside an element. Set it to a value such as 24px to replace the browser’s default size. section 4.4

Use font-size to:

  • Set deliberate sizes for headings, body text, captions, sidebars, navigation, and other page elements instead of relying on defaults. section 4.4
  • Choose relative units such as em when text should respond to the browser’s or user’s default font size. section 14.9
  • Remember that font-size can inherit: child and descendant elements may receive styling from a parent. section 14.9

Make a div’s text larger

div { font-size: 24px; } This renders text inside the div at 24 pixels, while a paragraph using the browser default remains 16 pixels in modern browsers. section 4.4

div {                   #1
    font-size: 24px;    #1
}                       #1

Inspect the compact CSS listing showing the property, value, and px unit together. section 4.4

How Web Design Playground, Second Edition covers it

How deep it goes
Defines pixel and relative sizing, inheritance, and browser defaults, while deferring the full range of CSS measurement units.
Examples
Demonstrates a 24px div, a default-sized paragraph, user font-size settings, and nested em calculations.
What it assumes
Assumes basic HTML elements and CSS declarations while teaching type-size control from browser defaults.
What you can do after
Apply font-size declarations in pixels or relative units and anticipate how defaults and inheritance affect rendered text.
How it connects
Connects typography with browser defaults, CSS inheritance, relative units, and responsive web design.

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 Web Design Playground, Second Edition. The section links point to the parts of the book it draws on.