텍스트가 특정 픽셀 수만 사용하도록 글꼴 크기를 픽셀 단위로 지정할 수 있습니다. 픽셀 크기는 화면의 해상도와 브라우저에서 계산하는 알고리즘을 기반으로 합니다.
구문
CSS font-size 속성의 구문은 다음과 같습니다 -
Selector {
font-size: /*value*/
} 예시
다음 예는 CSS font-size 속성이 픽셀로 설정되는 방법을 보여줍니다 -
<!DOCTYPE html>
<html>
<head>
<style>
span {
background-color: darkseagreen;
padding: 20px;
font-size: 15px;
}
span:nth-child(3) {
font-size: 55px;
}
span:last-child {
font-size: 25px;
}
</style>
</head>
<body>
<br/>
<span>one</span><span>two</span><span>three</span>
</body>
</html> 출력
이것은 다음과 같은 출력을 제공합니다 -

예시
<!DOCTYPE html>
<html>
<head>
<style>
div {
width: 40%;
border: 2px solid yellow;
padding: 20px;
font-size: 10px;
}
div:nth-child(3) {
font-size: 20px;
}
div:last-child {
font-size: 30px;
}
</style>
</head>
<body>
<br/>
<div>one</div>
<div>two</div>
<div>three</div>
</body>
</html> 출력
이것은 다음과 같은 출력을 제공합니다 -
