font-sizeの使い方
Web標準HTML/CSS > font-sizeの使い方
font-size
プロパティの説明
font-sizeは、文字の大きさを指定するプロパティです。全ての要素に指定することができます。
指定できる値
- CSSで使える数値
- 12px, 0.75em, 100%などで大きさを変化させる。
- xx-small, x-small, small, medium, large, x-large, xx-large
- 七段階の文字の大きさにする。
- larger, smaller
- 親要素よりも一段階大きさを変化させる。
サンプル
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"https://www.w3.org/TR/html4/strict.dtd">
<html lang="ja">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Style-Type" content="text/css">
<title>サンプルページ</title>
<style type="text/css">
<!--
.px{font-size:12px;}
.em{font-size:1.5em;}
.xl{font-size:x-large;}
.lr{font-size:larger;}
-->
</style>
</head>
<body>
<h1>サンプルページ</h1>
<p>通常サイズ。</p>
<p class="px">pxで大きさを指定。</p>
<p class="em">emで大きさを指定。</p>
<p class="xl">x-largeで大きさを指定。</p>
<p class="lr">largerで大きさを指定。</p>
</body>
</html>