![Internet Explorer4](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_i4.gif)
![Internet Explorer5](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_i5.gif)
![Internet Explorer5-mac](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_i5mac.gif)
![Internet Explorer5.5](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_i55.gif)
![Internet Explorer6](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_i6.gif)
![Internet Explorer7](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_i7.gif)
![Internet Explorer8](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_i8.gif)
![Internet Explorer9](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_i9.gif)
![Netscape4](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_n4.gif)
![Netscape6](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_n6.gif)
![Netscape7](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_n7.gif)
![Netscape8](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_n8.gif)
![Opera6](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_o6.gif)
![Opera7](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_o7.gif)
![Opera8](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_o8.gif)
![Opera9](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_o9.gif)
![Opera10](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_o10.gif)
![Firefox1](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_f1.gif)
![Firefox2](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_f2.gif)
![Firefox3](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_f3.gif)
![Firefox4](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_f4.gif)
![Google Chrome1](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_gc1.gif)
![Google Chrome2](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_gc2.gif)
![Google Chrome3](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_gc3.gif)
![Google Chrome4](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_gc4.gif)
![Google Chrome5](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_gc5.gif)
![Google Chrome6](https://htmqcom1.wpengine.com/wp-content/uploads/2024/07/b_gc6.gif)
paddingプロパティは、上下左右のパディングをまとめて指定する際に使用します。
上下左右を異なるパディング幅にしたい場合には、スペースで区切って複数の値を指定します。
値を1つ指定した場合: | 指定した値が[上下左右]のパディングになります。 |
値を2つ指定した場合: | 記述した順に[上下][左右]のパディングになります。 |
値を3つ指定した場合: | 記述した順に[上][左右][下]のパディングになります。 |
値を4つ指定した場合: | 記述した順に[上][右][下][左]のパディングになります。 |
パディングはマージンとセットで覚えるのが良いと思います。
マージンは領域間のスペース、パディングは領域内のスペースです。
尚、パディングには負の値を指定することはできません。
■使用例
スタイルシート部分は外部ファイル(sample.css)に記述。
p.sample1 {background-color: #f8dce0; padding: 10px;}
p.sample2 {background-color: #f8dce0; margin: 30px; padding: 10px;}
p.sample3 {background-color: #f8dce0; padding: 10px 20px;}
p.sample4 {background-color: #f8dce0; padding: 10px 20px 30px;}
p.sample5 {background-color: #f8dce0; padding: 10px 20px 30px 40px;}
HTMLソース
<html>
<head>
<link rel=”stylesheet” href=”sample.css”
type=”text/css”>
</head>
<body>
<p class=”sample1″>
このサンプルでは上下左右にまとめて10pxのパディングを指定しています。パディングには負の値を指定することはできません。
</p>
<p class=”sample2″>
このサンプルでは上下左右にまとめて30pxのマージンと、10pxのパディングを指定しています。パディングには負の値を指定することはできません。
</p>
<p class=”sample3″>
このサンプルでは上下10px、左右20pxのパディングを指定しています。パディングには負の値を指定することはできません。
</p>
<p class=”sample4″>
このサンプルでは上10px、左右20px、下30pxのパディングを指定しています。パディングには負の値を指定することはできません。
</p>
<p class=”sample5″>
このサンプルでは上10px、右20px、下30px、左40pxのパディングを指定しています。パディングには負の値を指定することはできません。
</p>
</body>
</html>
ブラウザ上の表示
このサンプルでは上下左右にまとめて10pxのパディングを指定しています。パディングには負の値を指定することはできません。
このサンプルでは上下左右にまとめて30pxのマージンと、10pxのパディングを指定しています。パディングには負の値を指定することはできません。
このサンプルでは上下10px、左右20pxのパディングを指定しています。パディングには負の値を指定することはできません。
このサンプルでは上10px、左右20px、下30pxのパディングを指定しています。パディングには負の値を指定することはできません。
このサンプルでは上10px、右20px、下30px、左40pxのパディングを指定しています。パディングには負の値を指定することはできません。
■関連項目
margin-top …… 上マージンを指定する
margin-bottom …… 下マージンを指定する
margin-left …… 左マージンを指定する
margin-right …… 右マージンを指定する
padding …… パディングに関する指定をまとめて行う
padding-top …… 上パディングを指定する
padding-bottom …… 下パディングを指定する
padding-left …… 左パディングを指定する
padding-right …… 右パディングを指定する