サイト内検索
...HTML・XHTMLタグ...
table・セル
セル内のサイズの指定
- セル内のサイズ
- 横幅は、td要素・th要素にwidth属性を指定します。
- 高さは、td要素・th要素にheight属性を指定します。
- 数値を指定します。
- [使い方]
- <th width="10" height="20">〜</th>
- <td width="10" height="20">〜</td>
- [メモ・・・W3Cの検証サービス・・・]
- HTML 4.01 Strict ・ XHTML1.0 Strictでは、推奨されていませんので、
- Validするには、スタイルシートを使用します。
- widthプロパティ・heightプロパティを指定します。
- .sample{width: 40px; height: 40px;}
- [ブラウザによっては]height=""を指定します。
属性 | 属性値 | 説明 |
---|---|---|
width= | "" | 横幅の指定をします。
整数の「ピクセル数(例・・"1")」 または 「パーセント(例・・"50%")」を指定します。 |
height= | "" | 長さの指定をします。
整数の「ピクセル数(例・・"1")」 または 「パーセント(例・・"50%")」を指定します。 |
サンプル
《「%」を指定》
[bodyの中]
<table border="1" width="100" height="150"><tr>
<th width="30%" height="30%">No1</th>
<td width="70%">No2</td>
</tr>
<tr>
<td height="70%">No3</td>
<td height="70%">No4</td>
</tr>
</table>
《幅を同じにして高さを変えると》
[bodyの中]
<table border="1"><tr>
<th width="120" height="40">No1</th>
<td width="120" height="40">No2</td>
</tr>
<tr>
<td width="120" height="80">No3</td>
<td width="120" height="80">No4</td>
</tr>
</table>
width:・height: を指定
《「%」を指定》
[bodyの中]
<table border="1" style="width: 200px; height: 150px;"><tr>
<th style="width: 30%; height: 30%;">No1</th>
</tr>
<tr>
<td style="width: 120px; ">No2</td>
</tr>
<tr>
<td style="height: 70%;">No3</td>
<td style="height: 70%;">No4</td>
</tr>
</table>
[ブラウザ上]
No1 | No2 |
---|---|
No3 | No4 |
《幅を同じにして高さを変えると》
[bodyの中]
<table border="1"><tr>
<th style="width: 120px; height: 20px;">No1</th>
</tr>
<tr>
<td style="width: 120px; height: 40px;">No2</td>
</tr>
<tr>
<td style="width: 120px; height: 60px;>No3</td>
</tr>
</table>
[ブラウザ上]
No1 |
---|
No2 |
No3 |