็ก์
font ์์ฑ ๋ณธ๋ฌธ
๐ขโ โfont
์น ํ์ด์ง์ ๊ธ๊ผด ์คํ์ผ, ํฌ๊ธฐ, ๊ตต๊ธฐ, ์ค ๋์ด ๋ฑ์ ์ค์ ํ๋ ์์ฑ.
๐น font-family (๊ธ๊ผด ์ข ๋ฅ)
ํ ์คํธ์ ์ ์ฉํ ๊ธ๊ผด(font)์ ์ข ๋ฅ๋ฅผ ์ง์ ํ๋ ์์ฑ.
body {
font-family: 'Pretendard', 'Apple SD Gothic Neo', sans-serif;
}
- ๋ฌธ๋ฒ: ์ฌ์ฉ์์ ์ปดํจํฐ์ ํด๋น ํฐํธ๊ฐ ์์ ๊ฒฝ์ฐ๋ฅผ ๋๋นํด ์ฌ๋ฌ ๊ฐ์ ํ๋ณด ๊ธ๊ผด์ ์ผํ๋ก ๊ตฌ๋ถํ์ฌ ์์ฑํ๋ค.
- Generic Family (ํ๊ทธ): ๋ง์ง๋ง์๋ ์ผ๋ฐ์ ์ธ ๊ธ๊ผด ๊ณ์ด์ ์จ์ ๋์ฒด ํฐํธ๊ฐ ์๋ํ๊ฒ ํ๋ค.
- serif: ๋์ ์ฅ์์ด ์๋ ๊ธ๊ผด.
- sans-serif: ์ฅ์์ด ์๋ ๊ธ๊ผด.
- monospace: ๊ธ์ ํญ์ด ๋์ผํ ๊ธ๊ผด.
- cursive: ํ๊ธฐ์ฒด ๊ธ๊ผด.
- fantasy: ์ฅ์์ ์ธ ๊ธ๊ผด.
- ์ฃผ์ ์ฌํญ: ๊ธ๊ผด ์ด๋ฆ์ ๊ณต๋ฐฑ์ด ์์ผ๋ฉด ๋ฐ์ดํ ์ฌ์ฉ. (' ')
๐น font-size (๊ธ์ ํฌ๊ธฐ)
ํ ์คํธ์ ํฌ๊ธฐ๋ฅผ ์กฐ์ ํ๋ ์์ฑ.
- ์ ๋ ๋จ์ (px(ํฝ์ )): ํ๋ฉด ํฌ๊ธฐ๋ ๋ถ๋ชจ ์์์ ์๊ด์์ด ๊ณ ์ ๋ ํฌ๊ธฐ.
- ์๋ ๋จ์ (rem, em, %): ๋ค๋ฅธ ์์๋ฅผ ๊ธฐ์ค์ผ๋ก ๊ณ์ฐ๋๋ ๋จ์.
- Viewport ๋จ์ (vw, vh, vmin/vmax): ๋ธ๋ผ์ฐ์ ํ๋ฉด ํฌ๊ธฐ ๊ธฐ์ค.
- ํค์๋ ๋จ์ ( small, medium, large): CSS์์ ๋ฏธ๋ฆฌ ์ ์๋ ๊ธ์ ํฌ๊ธฐ.
โ ์ถ์ฒ ๋ฐฉ์ (ํ๋ ์น ๊ฐ๋ฐ) โ
๊ธฐ๋ณธ: rem
๊ณ ์ UI: px
๋ฐ์ํ: vw, rem
๐น font-style (๊ธ์ ์คํ์ผ)
ํ ์คํธ์ ๊ธฐ์ธ๊ธฐ๋ฅผ ์ค์ ํ๋ ์์ฑ.
- normal: ๊ธฐ๋ณธ ๊ธ์ ์คํ์ผ. (๊ธฐ๋ณธ๊ฐ)
- italic: ๊ธ์๊ฐ ์ค๋ฅธ์ชฝ์ผ๋ก ๊ธฐ์ธ์ด์ง ์ดํ๋ฆญ์ฒด(๊ธฐ์ธ์๊ผด)๋ก ํ์. (๊ฐ์กฐ)
- oblique: ๊ธฐ๋ณธ ๊ธ์๋ฅผ ์ธ์์ ์ผ๋ก ๊ธฐ์ธ์ธ ๊ฒ์ผ๋ก ํฐํธ์ italic์ด ์์ ๋ ์ฌ์ฉํ๋ค.
๐น font-weight (๊ธ์ ๊ตต๊ธฐ)
ํ ์คํธ์ ๊ตต๊ธฐ(๋๊ป)๋ฅผ ์ค์ ํ๋ ์์ฑ.
- ์ฃผ์ ๊ฐ (Keyword):
- normal: ๊ธฐ๋ณธ ๊ธ์ ๊ตต๊ธฐ.
- bold: ๊ตต์ ๊ธ์จ.
- bolder: ๋ถ๋ชจ ์์๋ณด๋ค ๋ ๊ตต๊ฒ ํ์.
- lighter: ๋ถ๋ชจ ์์๋ณด๋ค ๋ ์๊ฒ ํ์.
- ์ซ์ ๊ฐ:
- 100๋ถํฐ 900๊น์ง 100 ๋จ์๋ก ์ธ๋ฐํ๊ฒ ์กฐ์ ํ ์ ์๋ค.
- 400์ normal๊ณผ ๊ฐ๊ณ , 700์ bold์ ์ ์ฌํ๋ค.
๐น font (ํฐํธ ์ถ์ฝ ์์ฑ)
์ฌ๋ฌ ๊ธ์ ๊ด๋ จ ์์ฑ์ ํ ์ค๋ก ์ค์ ํ ์ ์๋ ์ถ์ฝํ ์์ฑ.
p {
font: italic small-caps bold 16px/24px Arial, sans-serif;
}
- ๊ธฐ๋ณธ ์์: font-style → font-variant → font-weight → font-size/line-height → font-family (๊ตต์ ๊ธ์จ๋ ํ์ ์์ฑ)
- ํ์ ์์ฑ: font-size, font-family (๋ฐ๋์ ๋ง์ง๋ง ๋ถ๋ถ์ ์์ผํ๋ค.)
๐โ POINT ๐โ
โ๏ธ ์น ์ ๊ทผ์ฑ์ ๋์ด๊ธฐ ์ํด ํ ์คํธ์ ํฌ๊ธฐ๋ px(๊ณ ์ ํฌ๊ธฐ)๋ณด๋ค๋ rem(์ฌ์ฉ์ ์ค์ ์ ๋ฐ๋ผ ํ๋/์ถ์ ๊ฐ๋ฅ) ์ฌ์ฉ. โ๏ธ
โ๏ธ ์ฑ๋ฅ ์ต์ ํ๋ฅผ ์ํด ์น ํฐํธ(Google Fonts ๋ฑ) ์ฌ์ฉ ์ ์ต์ํ์ font-weight ์ฌ์ฉ. โ๏ธ
๐ ํฐํธ ์ฃผ์ ์์ฑ ์์ฝํ ๐
| ์์ฑ | ์ค๋ช | ์ฃผ์ ๊ฐ ์์ |
| font-family | ์์ฒด ์ง์ | "Roboto", sans-serif |
| font-size | ๊ธ์ ํฌ๊ธฐ | 16px, 1.2rem |
| font-style | ๊ธฐ์ธ์ ์ฌ๋ถ | italic, normal |
| font-weight | ๊ตต๊ธฐ ์กฐ์ | bold, 400, 700 |
โ๏ธ ์คโ์ ์์ ์ฝ๋ โ๏ธ
<!DOCTYPE html>
<html lang="ko">
<head>
<style>
/* 1. ์น ํฐํธ ์ธ๋ถ ์ฐ๊ฒฐ (์์: ๋๋๊ณ ๋) */
@import url('https://fonts.googleapis.com/css2?family=Nanum+Gothic:wght@400;700;800&display=swap');
body {
/* font-family: ๊ธฐ๋ณธ ์์ฒด ์ค์ (์์คํ
ํฐํธ -> ์์ธ๋ฆฌํ ์) */
font-family: 'Nanum Gothic', 'Malgun Gothic', sans-serif;
line-height: 1.6;
}
.title {
/* font-size: ์๋ ๋จ์ rem ์ฌ์ฉ (1rem = ๋ณดํต 16px) */
font-size: 2.5rem;
/* font-weight: ์ซ์๋ก ์ธ๋ฐํ๊ฒ ๊ตต๊ธฐ ์ง์ */
font-weight: 800;
color: #333;
}
.subtitle {
/* font-style: ๊ธฐ์ธ์๊ผด ์ ์ฉ */
font-style: italic;
font-size: 1.2rem;
font-weight: 400;
color: #666;
}
.bold-text {
/* font-weight: ํค์๋๋ก ๊ตต๊ฒ ์ง์ */
font-weight: bold;
}
.shorthand {
/* font ์ถ์ฝํ: [style] [weight] [size] [family] */
font: italic 700 18px 'Nanum Gothic', sans-serif;
margin-top: 20px;
color: royalblue;
}
</style>
</head>
<body>
<h1 class="title">๋๋ง์ ์น ํ์ดํฌ๊ทธ๋ํผ</h1>
<p class="subtitle">CSS ํฐํธ ์์ฑ์ ํ์ฉํ ์คํ์ผ๋ง ์์ ์
๋๋ค.</p>
<p>์ด ๋ฌธ์ฅ์ ์ผ๋ฐ์ ์ธ ๊ตต๊ธฐ์ ํ
์คํธ์
๋๋ค.</p>
<p class="bold-text">์ด ๋ฌธ์ฅ์ font-weight: bold๊ฐ ์ ์ฉ๋์ด ๊ฐ์กฐ๋์์ต๋๋ค.</p>
<div class="shorthand">
์ถ์ฝํ ์์ฑ(shorthand)์ ์ฌ์ฉํ์ฌ ํ ์ค๋ก ์ ์ํ ์คํ์ผ์
๋๋ค.
</div>
</body>
</html>
'<style>' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
| color ์์ฑ (0) | 2026.03.17 |
|---|---|
| Web font (0) | 2026.03.16 |
| ์ฐ์ ์์(Precedence)์ ์์(Inheritance) (0) | 2026.03.13 |
| Selectors (์ ํ์) ํ์ (0) | 2026.03.13 |
| CSS์ Style sheet (0) | 2026.03.12 |