Stijl lettertype Eigenschap
Voorbeeld
Stel het lettertype voor een element in:
document.getElementById("demo").style.font = "italic bold 20px arial,serif";
Definitie en gebruik
De eigenschap font stelt maximaal zes afzonderlijke font-eigenschappen in of retourneert deze in verkorte vorm.
Met deze eigenschap kunt u (in deze volgorde) het volgende instellen/retourneren:
- lettertype
- lettertype-variant
- lettertype dikte
- lettertypegrootte
- lijnhoogte
- font-familie
De lettergrootte en de letterfamilie zijn vereist. Als een van de andere waarden ontbreekt, worden de eventuele standaardwaarden ingevoegd.
Bovenstaande eigenschappen kunnen ook met aparte stijleigenschappen worden ingesteld. Het gebruik van aparte eigenschappen wordt ten zeerste aanbevolen voor niet-gevorderde auteurs voor een betere beheersbaarheid.
Browserondersteuning
Property | |||||
---|---|---|---|---|---|
font | Yes | Yes | Yes | Yes | Yes |
Syntaxis
Retourneer de eigenschap font:
object.style.font
Stel de eigenschap font in:
object.style.font = "font-style font-variant font-weight font-size/line-height|caption|icon|menu|
message-box|small-caption|status-bar|initial|inherit;"
Eigendomswaarden
Value | Description |
---|---|
style | Sets the font-style |
variant | Sets the text in a small-caps font |
weight | Sets the boldness of the font |
size | Sets the size of the font |
lineHeight | Sets the distance between lines |
family | Sets the 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. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Technische details
Standaardwaarde: | niet gespecificeerd |
---|---|
Winstwaarde: | Een tekenreeks, die verschillende lettertype-eigenschappen van het element weergeeft |
CSS-versie | CSS1 |
Meer voorbeelden
Voorbeeld
Retourneer het lettertype van een element:
alert(document.getElementById("demo").style.font);
Gerelateerde pagina's
CSS-zelfstudie: CSS-lettertype
CSS-referentie: eigenschap font
❮ Stijlobject