Style fontWeight Attribute
- Vorherige Seite fontVariant
- Nächste Seite fontSizeAdjust
- Nach oben HTML DOM Style-Objekt
Definition and Usage
fontWeight
Sets or returns the thickness of the characters in the text.
See also:
CSS Tutorial:CSS-Schrift
CSS Reference Manual:font-weight Attribute
HTML DOM Reference Manual:font Property
Example
Example 1
Set the font weight of the <p> element to "900":
document.getElementById("myP").style.fontWeight = "900";
Example 2
Demonstration of possible values:
var listValue = selectTag.options[selectTag.selectedIndex].text; document.getElementById("myP").style.fontWeight = listValue;
Example 3
Return the font weight of the <p> element:
alert(document.getElementById("myP").style.fontWeight);
Syntax
Return fontWeight property:
object.style.fontWeight
Set fontWeight property:
object.style.fontWeight = "normal|lighter|bold|bolder|value|initial|inherit"
Attribute Value
Value | Description |
---|---|
normal | The font is normal. Default. |
lighter | The font is thinner. |
bold | The font is bold. |
bolder | The font is thicker. |
|
Define the character from thin to bold. 400 is the same as normal, 700 is the same as bold. |
initial | Sets this property to its default value. See also initial. |
inherit | Inherits this property from its parent element. See also inherit. |
Technical Details
Default value: | normal |
---|---|
Return value: | A string value that represents the weight of the font. |
CSS Version: | CSS1 |
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Unterstützung | Unterstützung | Unterstützung | Unterstützung | Unterstützung |
- Vorherige Seite fontVariant
- Nächste Seite fontSizeAdjust
- Nach oben HTML DOM Style-Objekt