Javascript examples for CSS Style Property:fontFamily
The fontFamily property sets or gets a list of font-family names and/or generic-family names for text.
font-family: The name of a font-family, like "verdana" or "arial"
generic-family: The name of a generic font-family, like "serif" or "sans-serif"
Separate each value with a comma. If a font-family name contains whitespace, it must be quoted.
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. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | not specified |
Return Value: | A String, representing the font name of the text in the element |
CSS Version | CSS1 |
Get the font for a <p> element:
<!DOCTYPE html> <html> <body> <p id="myP" style="font-family:Arial,Helvetica,sans-serif;">This is a paragraph, shown in the Arial font.</p> <button type="button" onclick="myFunction()">Return font</button> <script> function myFunction() {/* w w w . j a va2s .c om*/ console.log(document.getElementById("myP").style.fontFamily); } </script> </body> </html>