サイト内検索

...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%">No</th>
<td width="70%">No</td>
</tr>
<tr>
<td height="70%">No</td>
<td height="70%">No</td>
</tr>
</table>

《幅を同じにして高さを変えると》

[bodyの中]

<table border="1">
<tr>
<th width="120" height="40">No</th>
<td width="120" height="40">No</td>
</tr>
<tr>
<td width="120" height="80">No</td>
<td width="120" height="80">No</td>
</tr>
</table>

width:・height: を指定

《「%」を指定》

[bodyの中]

<table border="1" style="width: 200px; height: 150px;">
<tr>
<th style="width: 30%; height: 30%;">No</th>
</tr>
<tr>
<td style="width: 120px; ">No</td>
</tr>
<tr>
<td style="height: 70%;">No</td>
<td style="height: 70%;">No</td>
</tr>
</table>

[ブラウザ上]

No No
No No

《幅を同じにして高さを変えると》

[bodyの中]

<table border="1">
<tr>
<th style="width: 120px; height: 20px;">No</th>
</tr>
<tr>
<td style="width: 120px; height: 40px;">No</td>
</tr>
<tr>
<td style="width: 120px; height: 60px;>No</td>
</tr>
</table>

[ブラウザ上]

No
No
No

Copyright c 2007.10.01 luc All rights reserved.