

If the font name contains a space it must be quoted. It is good practice to have a common generic font-family last in the list. Browsers will use the first available to them. You can not use the tag in XHTML 1.0 Strict. Sets a list of one or more font families to be used in order of preference. Using font-family: Arial is a pretty safe bet, since almost all computers have the Arial font, but to be safe it is best to include a couple of fall-back. The browser will use the first one in the stack that it happens to recognize (installed on the computer).
#Font family in html how to
The sixth tag shows how to combine the color, face, and size together in the same tag. The font-family property accepts a stack (comma-separated list) of font family names. In this XHTML 1.0 Transitional Document example, we have 6 tag examples. While they are practical and popular, they might not be of much use if you want to create a unique design.

If you created a new web page in XHTML 1.0 Transitional, your tag might look like this: By default, you can only choose from a handful of web-safe fonts to use in CSS. Since not all fonts are available on all computers (there are thousands of fonts, and most are not free), CSS provides a system of fallbacks. On this page I won't show any 'tricks,' but I will show the range of font variations that CSS allows. The sixth tag shows how to combine the color, face, and size together in the same tag. After the color, the font is probably the most basic property of a page. The fourth tag shows how to set the font size using a numeric value while the fifth tag shows how to set the font size using a relative value. The third tag shows how to set the font face with a comma separate list of font families to use. To change the font family of a HTML Element using JavaScript, get reference to the element, and assign required font family value to the element.style. The browser will look for each family on the users computer and in any font-face resource. The first tag shows how to set the font color with a named color while the second tag shows how to set the font color with a hexadecimal value. font-family: 'Source Sans Pro', 'Arial', sans-serif When using multiple values, the font-family list of font families defines the priority in which the browser should choose the font family. In this HTML 4.01 Transitional Document example, we have 6 tag examples. If you created a new web page in HTML 4.01 Transitional, your tag might look like this: Įxample 1 font color is red using a named colorĮxample 2 font color is red using hexadecimal formatĮxample 3 font face is a different font familyĮxample 4 font size is 5 using numeric valueĮxample 5 font size is two font sizes bigger using a relative value
