Style fontWeight attribute
- Προηγούμενη σελίδα fontVariant
- Επόμενη σελίδα fontSizeAdjust
- Επιστροφή στο προηγούμενο επίπεδο Αντικείμενο Style HTML DOM
Definition and usage
fontWeight
Sets or returns the thickness of the text characters.
See also:
CSS Tutorial:Γραμματοσειρά CSS
CSS Reference Manual:font-weight attribute
HTML DOM Reference Manual:font attribute
Instance
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
Returns 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 thick. 400 is the same as normal, 700 is the same as bold. |
initial | Sets this property to its default value. See initial. |
inherit | Inherits this property from its parent element. See inherit. |
Technical details
Default value: | normal |
---|---|
Return value: | A string value representing the thickness of the font. |
CSS version: | CSS1 |
Browser supports
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη | Υποστήριξη |
- Προηγούμενη σελίδα fontVariant
- Επόμενη σελίδα fontSizeAdjust
- Επιστροφή στο προηγούμενο επίπεδο Αντικείμενο Style HTML DOM