타이포그래피 테마 설정
Coddy HTML 여정의 실전 프론트엔드 섹션에 포함된 레슨. 35개 중 15번째.
Typography은 theming과 design의 중요한 part입니다. 어디에서나 font style을 작성하는 대신, 이를 CSS variables로 정의하고 사이트 전체에서 재사용할 수 있습니다. 이렇게 하면 style이 consistent하게 유지되고 나중에 변경하기도 더 쉬워집니다.
다음에 대한 변수를 정의할 수 있습니다:
- font family(예:
--font-family-base,--font-family-heading)
- Font sizes (예:
--font-size-base,--font-size-h1) - Line height
- 자간
First, :root 요소에서 typography variables를 정의해 보겠습니다:
:root {
--font-primary: 'Open Sans', sans-serif;
--font-secondary: 'Roboto', sans-serif;
--font-size-base: 16px;
--line-height: 1.5;
--heading-color: #333;
--text-color: #555;
}이제 이러한 variables를 text 요소에 적용하세요:
body {
font-family: var(--font-primary);
font-size: var(--font-size-base);
line-height: var(--line-height);
color: var(--text-color);
}
h1, h2, h3, h4, h5, h6 {
font-family: var(--font-secondary);
color: var(--heading-color);
}이 설정은 한 곳에서 변수 값을 변경하여 쉽게 수정할 수 있는 통합 typography 시스템을 creates합니다.
챌린지
쉬움블로그
- 다음 CSS variables를 정의하세요:
- headings의 Font sizes (
--h1-size및--h2-size) - paragraphs의 text color (
--text-color): 더 나은 가독성을 위해 순수한 검정색이 아닌 color를 선택하세요 - headings의 text color (
--heading-color): body text와 구별되는 color를 선택하세요
- headings의 Font sizes (
- 다음 요소를 style하기 위해 이 variables를 적용하세요:
- body text
- h1 및 h2 headings
CSS는 headings와 paragraphs text 사이에 명확한 visual hierarchy를 만들어야 합니다.
REQUIRED OUTPUT FORMAT:직접 해보기
<!DOCTYPE html>
<html>
<head>
<title>Typography Theming</title>
<style>
:root {
/* Typography variables */
--primary-font: "Georgia", serif; /* for paragraphs */
--secondary-font: "Arial", sans-serif; /* for headings */
}
body {
font-family: var(--primary-font);
color: #000000;
line-height: 1.6;
margin: 0;
padding: 20px;
background-color: #f9f9f9;
}
h1, h2 {
font-family: var(--secondary-font);
color: #000000;
margin-bottom: 0.5em;
}
h1 {
font-size: 16px;
}
h2 {
font-size: 16px;
}
p {
margin-bottom: 1.2em;
}
.blog-post {
max-width: 700px;
margin: 0 auto;
background: #fff;
padding: 2rem;
border-radius: 10px;
box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}
</style>
</head>
<body>
<div class="blog-post">
<h1>The Beauty of Typography in Web Design</h1>
<p>Typography plays a crucial role in how users read and experience content online. A good choice of fonts and sizes can make a website more readable and enjoyable.</p>
<h2>Why Typography Matters</h2>
<p>Clear and consistent typography improves accessibility, creates a visual hierarchy, and gives your website a professional feel. Without it, even the best design can look unpolished.</p>
<h2>Mobile-First Typography</h2>
<p>Starting with smaller, readable text for mobile and scaling up for desktops ensures your content looks great on any device. This approach is part of mobile-first design and theming.</p>
</div>
</body>
</html>
이 레슨에는 짧은 퀴즈가 포함되어 있습니다. 레슨을 시작해 문제를 풀고 진행 상황을 기록하세요.
실전 프론트엔드의 모든 레슨
직접 연습해 보세요: Web 플레이그라운드