스타일 textAlign 속성
예시
요소의 텍스트를 가운데 정렬:
document.getElementById("demo").style.textAlign = "center";
정의 및 사용
textAlign 속성은 블록 수준 요소에서 텍스트의 수평 정렬을 설정하거나 반환합니다.
브라우저 지원
Property | |||||
---|---|---|---|---|---|
textAlign | Yes | Yes | Yes | Yes | Yes |
통사론
textAlign 속성을 반환합니다.
object.style.textAlign
textAlign 속성을 설정합니다.
object.style.textAlign = "left|right|center|justify|initial|inherit"
속성 값
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 |
기술적 세부 사항
기본값: | 왼쪽 |
---|---|
반환 값: | 요소 내 텍스트의 수평 정렬을 나타내는 문자열 |
CSS 버전 | CSS1 |
더 많은 예
예시
요소의 텍스트 정렬을 반환합니다.
alert(document.getElementById("demo").style.textAlign);
관련 페이지
CSS 튜토리얼: CSS 텍스트
CSS 참조: text-align 속성
❮ 스타일 개체