CHAPTER 8

Formatting Text with CSS

CSS enables you to format the text in your web pages to make them look the way you want. Basic formatting includes the font family, the font size and font weight, and the font color. More advanced formatting includes line height and letter spacing, superscripts and subscripts, and text shadows. You can also insert special characters and emojis in your pages.

image

Understanding Fonts and How to Use Them

Specify the Font Family

Set the Font Size and Font Weight

Adjust Line Height and Letter Spacing

Create Superscripts and Subscripts

Understanding Ways to Set Color in CSS

Set Font Color

Apply Text Shadows

Display Monospaced Font

Apply Text Decoration

Understanding HTML Entities

Insert Special Characters with HTML Entities

Insert Emojis

Using Custom Fonts on Web Pages

Understanding Fonts and How to Use Them

Working with fonts is a crucial part of web development, because fonts control the appearance of text on your web pages and can help convey your website’s message, tone, and style. CSS gives you a wide variety of ways to control fonts and text styling, from essential properties such as font family and font size to more specialized properties such as superscripts, subscripts, and text shadows.

This section gives you an overview of the font properties you can control. The following sections show you how to effect changes in the properties.

Font Families ...

Get Teach Yourself VISUALLY HTML and CSS, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.