본문 바로가기
[Front-End] 프론트엔드/[css] 스타일시트

[css3] text-align 텍스트 정렬 소스 코드 예제

by codeomni 2018. 8. 29.
반응형

 

안녕하세요.

text-align 속성을 사용하면 쉽게 텍스트를 정렬할 수 있습니다.

속성에 사용할 수 있는 속성 값은 justify, left, center, right 가 있습니다.

 

-justify: 양쪽 정렬합니다.

-left: 왼쪽 정렬합니다.

-center: 가운데 정렬합니다.

-right: 오른쪽 정렬합니다.

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
<!DOCTYPE html>
<html>
    <head>
        <title>codeomni.tistory.com css3 text-align 텍스트 정렬 소스 코드 예제</title>
        <style>
            body {
                background-color: #9adaca;
            }
            #box {
                border: 3px solid;
                width: 400px;
                   padding: 10px;
            }
            #p1 {
                text-align: justify;
            }
            #p2 {
                text-align: left;
            }
            #p3 {
                text-align: center;
            }
            #p4 {
                text-align: right;
            }
        </style>
    </head>
    <body>
        <h1>codeomni</h1>
        <div id="box">
            <p id="p1">text-align: justify 텍스트 정렬</p>    
        </div>
        <div id="box">
            <p id="p2">text-align: left 텍스트 정렬</p>    
        </div>
        <div id="box">
            <p id="p3">text-align: center 텍스트 정렬</p>    
        </div>
        <div id="box">
            <p id="p4">text-align: right 텍스트 정렬</p>    
        </div>
    </body>
</html>
cs

 

 

 

실행 화면입니다.

 

 

 

댓글