글꼴의 더 나은 호환성을 위해 요소의 글꼴 크기를 지정하기 위해 퍼센트와 em의 조합을 사용할 수 있습니다. 이를 통해 다양한 브라우저에서 균일한 텍스트를 사용할 수 있습니다.
구문
CSS font-size 속성의 구문은 다음과 같습니다 -
Selector {
font-size: /*value*/
} 예시
다음 예는 CSS font-size 속성이 키워드로 설정되는 방법을 보여줍니다 -
<!DOCTYPE html>
<html>
<head>
<style>
body {
font-size: 80%;
}
p {
font-size: 2em;
}
span {
font-size: 4em;
font-style: italic;
}
</style>
</head>
<body>
<p>Reading <span>source code</span> written by others gives you opportunity to criticize the
mistakes done in writing that code</p>
</body>
</html> 출력
이것은 다음과 같은 출력을 제공합니다 -

예시
<!DOCTYPE html>
<html>
<head>
<style>
div {
font-size: 120%;
}
p {
font-size: 2em;
}
</style>
</head>
<body>
<h3>Demo Heading</h3>
This is example text.
<div>
Examples are easier to understand with practical implementation
<p>This is another text just to display different ways to set font size in CSS.</p>
</div>
</body>
</html> 출력
이것은 다음과 같은 출력을 제공합니다 -
