Teach Yourself VISUALLY™ HTML and CSS by Guy Hart-Davis

Teach Yourself VISUALLY™ HTML and CSS by Guy Hart-Davis

Author:Guy Hart-Davis [Hart-Davis, Guy]
Language: eng
Format: epub
Published: 2023-07-19T00:00:00+00:00


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

A font family is a set of typefaces that share a common design. For example, serif fonts have serifs, small projections finishing off the strokes of their letters, whereas sans-serif fonts have no serifs. Times New Roman and Baskerville are examples of serif fonts; Arial and Helvetica are examples of sans-serif fonts.

To specify the typeface used for text on a web page, you use the font-family property to set the font family. You can provide several values for font-family to specify fallback fonts in order of preference. For example, the following code specifies Helvetica, Arial, and sans-serif for the font family for the body element:

body {

font-family: Helvetica, Arial, sans-serif;

}

Here, if the web browser does not have Helvetica, it will fall back to Arial; if it does not have Arial either, it will fall back to the sans-serif font. The text will be displayed in some form, because the browser always has a serif font and a sans-serif font available.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.