Javascript examples for CSS Style Property:font
The font property sets or gets six separate font properties in a shorthand form:
Value | Description |
---|---|
style | font-style |
variant | text in a small-caps font |
weight | boldness of the font |
size | size of the font |
lineHeight | distance between lines |
family | font face |
caption | The font used for captioned controls (like buttons, drop-downs, etc.) |
icon | The font used to label icons |
menu | The font used in menus |
message-box | The font used in dialog boxes |
small-caption | The font used in small controls |
status-bar | The font used in window status bars |
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 different font properties of the element |
CSS Version | CSS1 |
Get the font for a <p> element:
<!DOCTYPE html> <html> <body> <p id="myP" style="font-weight:bold">This is a paragraph.</p> <button type="button" onclick="myFunction()">Return font weight</button> <script> function myFunction() {/*w w w .j a va 2 s.c o m*/ console.log(document.getElementById("myP").style.fontWeight); } </script> </body> </html>