Właściwość wyrównania tekstu w stylu
Przykład
Wyrównaj do środka tekst w elemencie:
document.getElementById("demo").style.textAlign = "center";
Definicja i użycie
Właściwość textAlign ustawia lub zwraca poziome wyrównanie tekstu w elemencie na poziomie bloku.
Obsługa przeglądarki
Property | |||||
---|---|---|---|---|---|
textAlign | Yes | Yes | Yes | Yes | Yes |
Składnia
Zwróć właściwość textAlign:
object.style.textAlign
Ustaw właściwość textAlign:
object.style.textAlign = "left|right|center|justify|initial|inherit"
Wartości nieruchomości
Value | Description |
---|---|
left | Aligns the text to the left. This is default |
right | Aligns the text to the right |
center | Centers the text |
justify | The text is justified |
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ść: | lewo |
---|---|
Wartość zwrotu: | String, reprezentujący poziome wyrównanie tekstu w elemencie |
Wersja CSS | CSS1 |
Więcej przykładów
Przykład
Zwróć wyrównanie tekstu elementu:
alert(document.getElementById("demo").style.textAlign);
Powiązane strony
Samouczek CSS: Tekst CSS
Odniesienie CSS: właściwość text-align
❮ Obiekt stylu