Style fontWeight Property
Przykład
Ustaw grubość czcionki dla elementu na „900”:
document.getElementById("demo").style.fontWeight = "900";
Definicja i użycie
Właściwość fontWeight ustawia lub zwraca, jak grube lub cienkie znaki w tekście powinny być wyświetlane.
Obsługa przeglądarki
Property | |||||
---|---|---|---|---|---|
fontWeight | Yes | Yes | Yes | Yes | Yes |
Składnia
Zwróć właściwość fontWeight:
object.style.fontWeight
Ustaw właściwość fontWeight:
object.style.fontWeight = "normal|lighter|bold|bolder|value|initial|inherit"
Wartości nieruchomości
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 |
Szczegóły techniczne
Domyślna wartość: | normalna |
---|---|
Wartość zwrotu: | String, reprezentujący pogrubienie czcionki |
Wersja CSS | CSS1 |
Więcej przykładów
Przykład
Demonstracja możliwych wartości:
var listValue = selectTag.options[selectTag.selectedIndex].text;
document.getElementById("demo").style.fontWeight = listValue;
Przykład
Zwróć grubość czcionki elementu:
alert(document.getElementById("demo").style.fontWeight);
Powiązane strony
Samouczek CSS: Czcionka CSS
Odniesienie CSS: właściwość font-weight
Odniesienie HTML DOM: właściwość czcionki
❮ Obiekt stylu