Stile fontWeight Property
Esempio
Imposta il peso del carattere per un elemento su "900":
document.getElementById("demo").style.fontWeight = "900";
Definizione e utilizzo
La proprietà fontWeight imposta o restituisce quanto devono essere visualizzati i caratteri spessi o sottili in un testo.
Supporto browser
Property | |||||
---|---|---|---|---|---|
fontWeight | Yes | Yes | Yes | Yes | Yes |
Sintassi
Restituisce la proprietà fontWeight:
object.style.fontWeight
Imposta la proprietà fontWeight:
object.style.fontWeight = "normal|lighter|bold|bolder|value|initial|inherit"
Valori di proprietà
Value | Description |
---|---|
normal | Font is normal. This is default |
lighter | Font is lighter |
bold | Font is bold |
bolder | Font is bolder |
100 200 300 400 500 600 700 800 900 |
Defines from light to bold characters. 400 is the same as normal, and 700 is the same as bold |
initial | Sets this property to its default value. Read about initial |
inherit | Inherits this property from its parent element. Read about inherit |
Dettagli tecnici
Valore di default: | normale |
---|---|
Valore di ritorno: | Una stringa, che rappresenta l'audacia del carattere |
Versione CSS | CSS1 |
Altri esempi
Esempio
Una dimostrazione di valori possibili:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontWeight = listValue;
Esempio
Restituisce il peso del carattere di un elemento:
alert(document.getElementById("demo").style.fontWeight);
Pagine correlate
Tutorial CSS: Font CSS
Riferimento CSS: proprietà font-weight
Riferimento HTML DOM: proprietà del carattere
❮ Oggetto stile