CSS 텍스트 정렬 속성
예시
다른 <div> 요소에 대한 텍스트 정렬을 설정합니다.
div.a {
text-align: center;
}
div.b {
text-align: left;
}
div.c {
text-align: right;
}
div.c {
text-align:
justify;
}
아래에서 더 많은 "직접 사용해 보기" 예를 살펴보세요.
정의 및 사용
text-align
속성은 요소에서 텍스트의 수평 정렬을 지정합니다 .
기본값: | 방향이 ltr이면 왼쪽, 방향이 rtl이면 오른쪽 |
---|---|
상속: | 네 |
애니메이션 가능: | 아니요. 애니메이션 가능 에 대해 읽기 |
버전: | CSS1 |
자바스크립트 구문: | 개체 .style.textAlign="오른쪽" |
브라우저 지원
표의 숫자는 속성을 완전히 지원하는 첫 번째 브라우저 버전을 지정합니다.
Property | |||||
---|---|---|---|---|---|
text-align | 1.0 | 3.0 | 1.0 | 1.0 | 3.5 |
CSS 구문
text-align: left|right|center|justify|initial|inherit;
속성 값
Value | Description | Play it |
---|---|---|
left | Aligns the text to the left | |
right | Aligns the text to the right | |
center | Centers the text | |
justify | Stretches the lines so that each line has equal width (like in newspapers and magazines) | |
initial | Sets this property to its default value. Read about initial | |
inherit | Inherits this property from its parent element. Read about inherit |
더 많은 예
예시
또 다른 텍스트 정렬 예:
h1 {
text-align: center;
}
p.date {
text-align: right;
}
p.main {
text-align: justify;
}
관련 페이지
CSS 튜토리얼: CSS 텍스트
HTML DOM 참조: textAlign 속성