CKTIS / CSS
Typography and text in CSS
CSS typography covers font selection and text layout: font size and weight, line height, spacing, alignment, and wrapping. Distinguishing font properties from layout properties helps you predict inheritance and text behavior.
Version: CSS modules; structured CSSWG indexes reconciled with pinned MDN BCD; Chromium 152 scope gate, per-example verification still required
Syntax
selector {
font-family: system-ui, sans-serif;
font-size: 20px;
font-weight: 400;
font-style: normal;
line-height: 1.5;
letter-spacing: normal;
word-spacing: normal;
text-align: start;
white-space: normal;
overflow-wrap: anywhere;
}Typography and text (typography and text) cover the appearance of characters and their arrangement. font-family supplies an ordered list of font families; the final sans-serif is a generic family. Font selection can happen per character, so one text fragment may use several fonts. font-size sets the font size, not the exact height of visible letters; font-weight controls weight, while font-style controls styles such as italics.
line-height participates in determining line heights, but is not the height of the drawn letters. A unitless value such as 1.5 is inherited as a multiplier: with font-size: 20px it yields 30px, while a descendant with font-size: 24px gets 36px. An inherited length such as 30px does not recalculate this way. Tall inline content can further enlarge a line.
letter-spacing and word-spacing control spacing, while text-align: start aligns text to the line's start according to its direction, not always to the left. white-space: normal collapses whitespace and allows wrapping; overflow-wrap: anywhere permits emergency breaks within a long string. These text and font properties are inherited unless the cascade establishes other values.
The example uses local fonts, so exact glyph shapes and line breaks may differ across systems. The expected computed values can be checked independently of appearance. CSSWG drafts describe the specification, not proof of browser support; the example requires separate verification.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Typography example</title>
<style>
.sample {
font-family: system-ui, sans-serif;
font-size: 20px;
font-weight: 400;
font-style: normal;
line-height: 1.5;
letter-spacing: normal;
word-spacing: normal;
text-align: start;
white-space: normal;
overflow-wrap: anywhere;
max-width: 240px;
}
.sample strong {
font-size: 24px;
font-weight: 700;
}
</style>
<p class="sample">Readable text with <strong>emphasis</strong> and a long token: abcdefghijklmnopqrstuvwxyz0123456789.</p>
</html>Result
The computed font-size is 20px for .sample and 24px for .sample strong. The computed line-height is the unitless number 1.5 on both elements. For line-height, getComputedStyle() returns the used values as resolved values: 30px for .sample and 36px for .sample strong. Text wraps within the paragraph; exact glyph shapes and line breaks depend on the available fonts.
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.