Text
1. ๊ฐ์
ํ ์คํธ ์คํ์ผ์ ์ฌ์ฉํ๋ ๊ธ์์ ๋ชจ์์๋ฅผ ์ง์ ํ๋ ๊ธ๊ผด ์คํ์ผ๊ณผ ์น ๋ฌธ์์ ํ์๋๋ ํ ์คํธ๋ฅผ ์ง์ ํ๋ ๋ฌธ๋จ ์คํ์ผ์ด ์๋ค.
2. line-height ํ๋กํผํฐ
ํ
์คํธ์ ๋์ด๋ฅผ ์ง์ ํ๋ค. ํ ๋ฌธ๋จ์ด ๋ ์ค์ด ๋์ผ๋ฉด ์ค ๊ฐ๊ฒฉ์ด ์๊ธด๋ค. ์ค ๊ฐ๊ฒฉ์ด ๋๋ฌด ์ข๊ฑฐ๋ ๋์ผ๋ฉด ๊ฐ๋
์ฑ์ด ๋จ์ด์ง๋ค. ์ด๋ line-height
์์ฑ์ ์ด์ฉํ๋ฉด ์ค ๊ฐ๊ฒฉ์ ์ํ๋ ๋งํผ ์กฐ์ ํ ์ ์๋ค.
<!DOCTYPE html>
<html>
<head>
<style>
.small {
line-height: 70%;
}
.large {
line-height: 1.5;
}
.x-large {
line-height: 3;
}
</style>
</head>
<body>
<p>
๊ธฐ๋ณธ ์ค ๊ฐ๊ฒฉ<br />
๊ธฐ๋ณธ ์ค ๊ฐ๊ฒฉ<br />
</p>
<p class="small">
์ข์ ์ค ๊ฐ๊ฒฉ<br />
์ข์ ์ค ๊ฐ๊ฒฉ<br />
line-height: 70%
</p>
<p class="large">
ํฐ ์ค ๊ฐ๊ฒฉ<br />
ํฐ ์ค ๊ฐ๊ฒฉ<br />
line-height: 1.5
</p>
<p class="x-large">
๋งค์ฐ ํฐ ์ค ๊ฐ๊ฒฉ<br />
๋งค์ฐ ํฐ ์ค ๊ฐ๊ฒฉ<br />
line-height: 3
</p>
</body>
</html>

๋ค์์ ์์ง ์ค์ ์ ๋ ฌ ์์ ์ด๋ค. a์์์ line-height
๊ฐ๊ณผ a์์๋ฅผ ๊ฐ์ธ๋ div
์์์ height
๊ฐ์ ์ผ์น์ํจ๋ค.
<!DOCTYPE html>
<html>
<head>
<style>
.btn {
width: 80px;
height: 40px;
background-color: orchid;
border-radius: 40px;
}
.btn > a {
display: block;
color: aliceblue;
text-align: center;
text-decoration: none;
line-height: 40px;
}
</style>
</head>
<body>
<div class="btn">
<a class="btn" href="#">Click</a>
</div>
</body>
</html>

3. letter-spacing ํ๋กํผํฐ
๊ธ์ ์ฌ์ด์ ๊ฐ๊ฒฉ์ ์ง์ ํ๋ค.
<!DOCTYPE html>
<html>
<head>
<style>
.ex1 {
letter-spacing: -2px;
}
.ex2 {
letter-spacing: 2px;
}
.ex3 {
letter-spacing: 10px;
}
</style>
</head>
<body>
<p>default letter spacing</p>
<p class="ex1">letter-spacing: -2px</p>
<p class="ex2">letter-spacing: 2px</p>
<p class="ex3">letter-spacing: 10px</p>
</body>
</html>

4. text-align ํ๋กํผํฐ
ํ ์คํธ์ ์ํ ์ ๋ ฌ์ ์ ์ํ๋ค. ํ๊ธ ๋ฌธ์์์ ํํ ์ฌ์ฉํ๋ ์ผ์ชฝ ์ ๋ ฌ, ์ค๋ฅธ์ชฝ ์ ๋ ฌ, ์์ชฝ ์ ๋ ฌ, ๊ฐ์ด๋ฐ ์ ๋ ฌ ๋ฑ์ ์น ๋ฌธ์์์๋ ์ง์ ํ ์ ์๋ค.
์๋์ ํ๋ text-align
์ ํ๋กํผํฐ๊ฐ์ด๋ค.
start
ํ์ฌ ํ ์คํธ ์ค์ ์์ ์์น์ ๋ง์ถ์ด ๋ฌธ๋จ์ ์ ๋ ฌํ๋ค.
end
ํ์ฌ ํ ์คํธ ์ค์ ๋ ์์น์ ๋ง์ถ์ด ๋ฌธ๋จ์ ์ ๋ ฌํ๋ค.
left
์ผ์ชฝ์ ๋ง์ถ์ด ๋ฌธ๋จ์ ์ ๋ ฌํ๋ค.
right
์ค๋ฅธ์ชฝ์ ๋ง์ถ์ด ๋ฌธ๋จ์ ์ ๋ ฌํ๋ค.
center
๊ฐ์ด๋ฐ์ ๋ง์ถ์ด ๋ฌธ๋จ์ ์ ๋ ฌํ๋ค.
justify
์์ชฝ์ ๋ง์ถ์ด ๋ฌธ๋จ์ ์ ๋ ฌํ๋ค.
match-parent
๋ถ๋ชจ ์์๋ฅผ ๋ฐ๋ผ ๋ฌธ๋จ์ ์ ๋ ฌํ๋ค.
<!DOCTYPE html>
<html>
<head>
<style>
p {
background-color: antiquewhite;
}
.start {
text-align: start;
}
.end {
text-align: end;
}
.left {
text-align: left;
}
.right {
text-align: right;
}
.center {
text-align: center;
}
.justify {
text-align: justify;
}
</style>
</head>
<body>
<p class="start">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odio esse in
amet quos aliquam temporibus dicta adipisci, magnam, corrupti velit quis
fugiat voluptatum provident possimus assumenda quaerat totam delectus
tempore.
</p>
<p class="end">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odio esse in
amet quos aliquam temporibus dicta adipisci, magnam, corrupti velit quis
fugiat voluptatum provident possimus assumenda quaerat totam delectus
tempore.
</p>
<p class="left">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odio esse in
amet quos aliquam temporibus dicta adipisci, magnam, corrupti velit quis
fugiat voluptatum provident possimus assumenda quaerat totam delectus
tempore.
</p>
<p class="right">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odio esse in
amet quos aliquam temporibus dicta adipisci, magnam, corrupti velit quis
fugiat voluptatum provident possimus assumenda quaerat totam delectus
tempore.
</p>
<p class="center">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odio esse in
amet quos aliquam temporibus dicta adipisci, magnam, corrupti velit quis
fugiat voluptatum provident possimus assumenda quaerat totam delectus
tempore.
</p>
<p class="justify">
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Odio esse in
amet quos aliquam temporibus dicta adipisci, magnam, corrupti velit quis
fugiat voluptatum provident possimus assumenda quaerat totam delectus
tempore.
</p>
</body>
</html>

5. text-decoration ํ๋กํผํฐ
text-decoration
ํ๋กํผํฐ๋ ํ
์คํธ์ ๋ฐ์ค์ ๊ธ๊ฑฐ๋ ์ทจ์์ ์ ํ์ํ๋ค. ๋งํฌ์ underline๋ฅผ ์ ๊ฑฐํ ์ ์์ผ๋ฉฐ ํ
์คํธ์ underline, overline, line-through๋ฅผ ์ถ๊ฐํ ์๋ ์๋ค.
<!DOCTYPE html>
<html>
<head>
<style>
a {
text-decoration: none;
}
p:nth-of-type(1) {
text-decoration: overline;
}
p:nth-of-type(2) {
text-decoration: line-through;
}
p:last-child {
text-decoration: underline;
}
</style>
</head>
<body>
<a href="#">text-decoratoin: none</a>
<p>text-decoration: overline</p>
<p>text-decoration: line-through</p>
<p>text-decoration: underline</p>
</body>
</html>

6. white-space ํ๋กํผํฐ
white space๋ ๊ณต๋ฐฑ(space), ๋ค์ฌ์ฐ๊ธฐ(tab), ์ค๋ฐ๊ฟ(line break)์ ์๋ฏธํ๋ค. html์ ๊ธฐ๋ณธ์ ์ผ๋ก ์ฐ์๋ ๊ณต๋ฐฑ, ๋ค์ฌ์ฐ๊ธฐ๋ 1๋ฒ๋ง ์คํ๋๋ฉฐ ์ค๋ฐ๊ฟ์ ๋ฌด์๋๋ค. ๋ํ ํ
์คํธ๋ ๋ถ๋ชจ์ ๊ฐ๋ก ์์ญ์ ๋ฒ์ด๋์ง ์๊ณ ์๋ ์ค๋ฐ๊ฟ(wrap)๋๋ค. white-space
ํ๋กํผํฐ๋ ์ด๋ฌํ ๊ธฐ๋ณธ ๋์์ ์ ์ดํ๊ธฐ ์ํ ํ๋กํผํฐ๋ค.
normal
๋ฌด์
1๋ฒ๋ง ๋ฐ์
O
nowrap
๋ฌด์
1๋ฒ๋ง ๋ฐ์
X
pre
๋ฐ์
๊ทธ๋๋ก ๋ฐ์
X
pre-wrap
๋ฐ์
๊ทธ๋๋ก ๋ฐ์
O
pre-line
๋ฐ์
1๋ฒ๋ง ๋ฐ์
O
<!DOCTYPE html>
<html>
<head>
<style>
body {
display: grid;
grid-template-columns: 1fr 1fr;
}
div {
width: 150px;
height: 150px;
border: 1px solid blueviolet;
margin-bottom: 120px;
}
h3 {
margin: 0;
}
.nomal {
white-space: normal;
}
.nowrap {
white-space: nowrap;
}
.pre {
white-space: pre;
}
.pre-wrap {
white-space: pre-wrap;
}
.pre-line {
white-space: pre-line;
}
</style>
</head>
<body>
<div class="nomal">
<h3>normal</h3>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore quo hic
aspernatur deserunt veritatis nemo, facilis totam autem laborum tempora
distinctio quae cum ut maxime obcaecati eligendi porro vitae praesentium.
</div>
<div class="nowrap">
<h3>nowrap</h3>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore quo hic
aspernatur deserunt veritatis nemo, facilis totam autem laborum tempora
distinctio quae cum ut maxime obcaecati eligendi porro vitae praesentium.
</div>
<div class="pre">
<h3>pre</h3>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore quo hic
aspernatur deserunt veritatis nemo, facilis totam autem laborum tempora
distinctio quae cum ut maxime obcaecati eligendi porro vitae praesentium.
</div>
<div class="pre-wrap">
<h3>pre-wrap</h3>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore quo hic
aspernatur deserunt veritatis nemo, facilis totam autem laborum tempora
distinctio quae cum ut maxime obcaecati eligendi porro vitae praesentium.
</div>
<div class="pre-line">
<h3>pre-line</h3>
Lorem ipsum dolor sit amet consectetur adipisicing elit. Tempore quo hic
aspernatur deserunt veritatis nemo, facilis totam autem laborum tempora
distinctio quae cum ut maxime obcaecati eligendi porro vitae praesentium.
</div>
</body>
</html>

7. text-overflow ํ๋กํผํฐ
๋ถ๋ชจ ์์ฌ๊ธใน ๋ฒ์ด๋ wrapping(์๋์ค๋ฐ๊ฟ)์ด ๋์ง ์์ ํ ์คํธ์ ์ฒ๋ฆฌ ๋ฐฉ๋ฒ์ ์ ์ํ๋ค.
์กฐ๊ฑด
width
ํ๋กํผํฐ๊ฐ ์ง์ ๋์ด ์์ด์ผ ํ๋ค. ์ด๋ฅผ ์ํด ํ์ํ ๊ฒฝ์ฐ block๋ ๋ฒจ ์์๋ก ๋ณ๊ฒฝํด์ผ ํ๋ค.์๋ ์ค๋ฐ๊ฟ์ ๋ฐฉ์งํ๋ ค๋ฉด
white-space
ํ๋กํผํฐ๋ฅผ nowrap์ผ๋ก ์ค์ ํ๋ค.overflow ํ๋กํผํฐ์ ๋ฐ๋์
visible
์ด์ธ์ ๊ฐ์ด ์ง์ ๋์ด ์์ด์ผ ํ๋ค.
์๋๋ text-overflow
ํ๋กํผํฐ์ ์ค์ ํ ์ ์๋ ํ๋กํผํฐ ๊ฐ์ด๋ค.
clip
์์ญ์ ๋ฒ์ด๋ ํ ์คํธ๋ฅผ ํ์ํ์ง ์๋๋ค.(๊ธฐ๋ณธ๊ฐ)
ellipsis
์์ญ์ ๋ฒ์ด๋ ํ ์คํธ๋ฅผ ์๋ผ๋ด์ด ๋ณด์ด์ง ์๊ฒ ํ๊ณ ๋ง์ค์ํ(...)๋ฅผ ํ์ํ๋ค.
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 150px;
height: 150px;
border: 1px solid blueviolet;
white-space: nowrap;
overflow: hidden;
display: inline-block;
}
h3 {
margin: 0;
}
.clip {
text-overflow: clip;
}
.ellipsis {
text-overflow: ellipsis;
}
</style>
</head>
<body>
<div class="clip">
<h3>clip</h3>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
</div>
<div class="ellipsis">
<h3>ellipsis</h3>
Lorem ipsum dolor sit amet consectetur adipisicing elit.
</div>
</body>
</html>

8. word-wrap ํ๋กํผํฐ
ํ ๋จ์ด์ ๊ธธ์ด๊ฐ ๊ธธ์ด์ ๋ถ๋ชจ ์์ญ์ ๋ฒ์ด๋ ํ ์คํธ์ ์ฒ๋ฆฌ ๋ฐฉ๋ฒ์ ์ ์ํ๋ค.
์ฌ์ฉ๋ฒ word-wrap: break-word;
9. word-break ํ๋กํผํฐ
word-wrap
ํ๋กํผํฐ์ ๊ฐ์ด ํ ๋จ์ด์ ๊ธธ์ด๊ฐ ๊ธธ์ด์ ๋ถ๋ชจ ์์ญ์ ๋ฒ์ด๋ ํ
์คํธ์ ์ฒ๋ฆฌ ๋ฐฉ๋ฒ์ ์ ์ํ๋ค. word-wrap
ํ๋กํผํฐ ๊ฒฝ์ฐ ๋จ์ด๋ฅผ ์ด๋ ์ ๋๋ ๊ณ ๋ คํ์ฌ ๊ฐํํ์ง๋ง word-break: break-all;
๋ ๋จ์ด๋ฅผ ๊ณ ๋ คํ์ง ์๊ณ ๋ถ๋ชจ ์์ญ์ ๋ง์ถ์ด ๊ฐ์ ๊ฐํํ๋ค.
์ฌ์ฉ๋ฒ word-break: break-all;
<!DOCTYPE html>
<html>
<head>
<style>
body {
display: flex;
justify-content: space-around;
}
div {
width: 150px;
height: 300px;
border: 1px solid black;
margin-bottom: 10px;
}
div:nth-of-type(2) {
word-wrap: break-word;
}
div:nth-of-type(3) {
word-break: break-all;
}
</style>
</head>
<body>
<div>abcdefghijklmnopqrstuvwxyz https://www.teachercan.com/</div>
<div>
word-wrap: break-word; abcdefghijklmnopqrstuvwxyz
https://www.teachercan.com/
</div>
<div>
word-break: break-all; abcdefghijklmnopqrstuvwxyz
https://www.teachercan.com/
</div>
</body>
</html>

10. text-transform ํ๋กํผํฐ
์๋ฌธ์๋ฅผ ํ๊ธฐํ ๋ ํ
์คํธ์ ๋์ ๋ฌธ์๋ฅผ ์ํ๋ ๋๋ก ๋ฐ๊ฟ ๋ text-transform
ํ๋กํผํฐ๋ฅผ ์ฌ์ฉํ๋ค. ํ๊ธ์๋ ์ํฅ์ ๋ฏธ์น์ง ์๊ณ ์๋ฌธ์์๋ง ์ ์ฉ๋๋ค.
์๋๋ text-transform
ํ๋กํผํฐ๊ฐ์ด๋ค.
capitalize
๊ฐ ๋จ์ด์ ์ฒซ ๋ฒ์งธ ๊ธ์๋ฅผ ๋๋ฌธ์๋ก ๋ณํํ๋ค.
uppercase
๋ชจ๋ ๊ธ์๋ฅผ ๋๋ฌธ์๋ก ๋ณํํ๋ค.
lowercase
๋ชจ๋ ๊ธ์๋ฅผ ์๋ฌธ์๋ก ๋ณํํ๋ค.
<!DOCTYPE html>
<html>
<head>
<style>
body {
display: flex;
justify-content: space-around;
}
.ex1 {
text-transform: capitalize;
}
.ex2 {
text-transform: uppercase;
}
.ex3 {
text-transform: lowercase;
}
</style>
</head>
<body>
<span class="ex1">hello world</span>
<span class="ex2">hello world</span>
<span class="ex3">HELLOW WORLD</span>
</body>
</html>

11. Conclusion
text๊ด๋ จ ํ๋กํผํฐ๋ ๋ง์ด ์ฌ์ฉ์ ํ์ง๋ง
white-space
,text-overflow
,word-wrap
,word-break
ํ๋กํผํฐ๋ ํฐ์ฒ์บ์ ๋ง๋ค ๋๋ง ์ฌ์ฉํ์ฌ ์ต์ํ์ง ์๋ ํ๋กํผํฐ์ด๋ค. ๊ทธ๋งํผ ๋ค๋ฅธ ํ๋กํผํฐ์ ๋นํด ๋น์ค์ด ๋จ์ด์ง๋ ๊ฑฐ ๊ฐ๋ค. ํ์ง๋ง ์น ํ์ด์ง๋ฅผ ๋ง๋ค๋ฉด์ ํ์ํ ์ํฉ์ด ์ฌ ์ ์๊ธฐ์ ํด๋น ํ๋กํผํฐ์ ํน์ง์ ์ ์์๋๊ณ ์์.
์ฐธ๊ณ
poiemaweb 2-7 ํฐํธ์ ํ ์คํธ ๋์ - HTML + CSS + ์๋ฐ์คํฌ๋ฆฝํธ ์น ํ์ค์ ์ ์
๐ 2022-07-19
Last updated