Fonts and Text
What Is It?
Typography properties control typeface, size, weight, line spacing, and alignment so content is comfortable to read.
Properties, Tags and Attributes Explained
font-family: An ordered list of fonts, ending with a generic fallback.font-size / font-weight: Set text size and thickness.line-height: Sets line box height; 1.6 means 1.6 times the font size.text-align / text-decoration: Control inline content alignment and decorations such as underlines.
Each example is a complete HTML page. The CSS is inside the head's style element. Use Try in new tab to edit the CSS or HTML, run your changes, and reset the example.
Example 1: Readable article
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fonts and Text</title>
<style>
article { font-family: system-ui, sans-serif; font-size: 1rem; line-height: 1.6; max-width: 38rem; }
h2 { font-weight: 700; }
</style>
</head>
<body>
<article><h2>A short lesson</h2><p>Short paragraphs and comfortable line spacing help readers scan and understand your content.</p></article>
</body>
</html>Browser preview
What you see: The article uses the system font and generous line spacing.
Example 2: Link and alignment
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Fonts and Text</title>
<style>
.caption { text-align: center; font-size: .875rem; }
a { color: #1d4ed8; text-decoration: underline; }
</style>
</head>
<body>
<p class="caption">Read the <a href="#details">course details</a>.</p><p id="details">Start with one small example.</p>
</body>
</html>Browser preview
What you see: A centered caption keeps its link visibly underlined.
When and Where to Use It
Use a readable base style for articles and stronger weights for headings. Keep link meaning visible.
Common Mistake or Useful Tip
text-align centers inline content; it does not center a block box itself.
Try It Yourself
Increase line-height and compare readability.