YouTip LogoYouTip

Prop Style Fontfamily

# Style fontFamily Property [![Image 8: Style Object Reference](#) Style Object](#) * * * ## Definition and Usage The fontFamily property sets or returns a list of font family names / generic font family names for the text in an element. The browser will use the first value it can recognize. There are two types of font family values: * font-family: A font family name, such as "verdana" or "arial". * generic-family: A generic font family name, such as "serif" or "sans-serif". **Tip:** Always specify a generic font family name as a last choice! **Note:** If the font family name contains spaces, please enclose it in quotes. **Tip:** See (#) for common font combinations. ## Syntax Set the fontFamily property: Object.style.fontFamily="_font1, font2, etc._|inherit" Get the fontFamily property: Object.style.fontFamily | Value | Description | | :--- | :--- | | _font1, font2, etc._ | A list of font family names / generic font family names, separated by commas. | | inherit | The fontFamily property's value is inherited from its parent element. | * * * ## Browser Support ![Image 9: Internet Explorer](#)![Image 10: Firefox](#)![Image 11: Opera](#)![Image 12: Google Chrome](#)![Image 13: Safari](#) All major browsers support the fontFamily property. **Note:** IE7 and earlier versions do not support the "inherit" value. IE8 only supports "inherit" if a !DOCTYPE is specified. IE9 supports "inherit". * * * ## Example ## Example Change the font of the text: function displayResult(){ document.getElementById("p1").style.fontFamily="Impact,Charcoal,sans-serif"; }

This is some text.


[Try it yourself Β»](#) * * Style Object](#) AI is thinking... [](#)[](#) (#)[](#)
← Prop Tablerow RowindexProp Style Font β†’