Set the font for a <p> element:
The fontFamily property sets or returns a list of font-family names and/or generic-family names for text in an element.
The browser will use the first value it recognizes.
There are two types of font-family values:
Tip: Always specify a generic-family name as the last alternative!
Note: Separate each value with a comma.
Note: If a font-family name contains whitespace, it must be quoted.
Tip: Look at Web safe fonts for commonly used font combinations.
The fontFamily property is supported in all major browsers.
Return the fontFamily property:
Set the fontFamily property:
Value | Description |
---|---|
font1, font2, etc. | A comma-separated list of font-family names and/or generic-family names |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Default Value: | not specified |
---|---|
Return Value: | A String, representing the font name of the text in the element |
CSS Version | CSS1 |
A demonstration of possible values:
Return the font of a <p> element:
CSS tutorial: CSS Font
CSS reference: font-family property
HTML DOM reference: font property