Section 5 : HTML 4 との記法の違い(2)

 Section 4 に続いて,さらに XHTML 1.0 と HTML 4 との記法の違いを見ていこう。

ブール値属性

 HTML 4 では,true/false の形で値を与える属性(input 要素の checked 属性,HTML 4 Transitional では th および td 要素の nowrap 属性,dl 要素の compact 属性など)および table 要素の frame 属性に値 border を与えるときは,属性名を省略して属性値のみを書くことが許されていた(そのように書かないと認識しない UA もある)。この記法は XHTML を含めた XML では許されておらず,省略しない完全な形で属性値を書かなくてはならない。

 次の例は HTML 4 としては正しが,XHTML 1.0 としては正しくない(ただし,次の例は HTML 4 Transitional である)。

<table border>
<caption>営団地下鉄と乗り入れ路線</caption>
<thead>
<tr><th>路線名</th><th>乗り入れ路線</th><th>乗り入れ先</th></tr>
</thead>
<tbody>
<tr><td rowspan="2" nowrap>日比谷線</td><td nowrap>東武伊勢崎線</td><td>北千住から東武動物公園</td></tr>
<tr><td nowrap>東急東横線</td><td>中目黒から菊名</td></tr>
<tr><td rowspan="3" nowrap>東西線</td><td nowrap>JR 中央線</td><td>中野から三鷹</td></tr>
<tr><td nowrap>JR 総武線</td><td>西船橋から津田沼</td></tr>
<tr><td nowrap>東葉高速線</td><td>西船橋から東葉勝田台</td></tr>
<tr><td rowspan="2" nowrap>千代田線</td><td nowrap>JR 常磐線</td><td>綾瀬から取手</td></tr>
<tr><td nowrap>小田急線</td><td>代々木上原から本厚木</td></tr>
<tr><td rowspan="2" nowrap>有楽町線</td><td nowrap>東武東上線</td><td>和光市から森林公園</td></tr>
<tr><td nowrap>西武有楽町線経由池袋線</td><td>小竹向原から飯能</td></tr>
<tr><td nowrap>半蔵門線</td><td nowrap>東急田園都市線</td><td>渋谷から中央林間</td></tr>
<tr><td rowspan="2" nowrap>南北線</td><td nowrap>東急目黒線</td><td>目黒から武蔵小杉</td></tr>
<tr><td nowrap>埼玉高速鉄道線</td><td>赤羽岩淵から浦和美園</td></tr>
</tbody>
</table>

XHTML 1.0 Transitional として正しいものとするには,ブール値属性 nowrap を省略しない形 nowrap="nowrap"frame 属性を frame="border" と書き直す。

<table frame="border">
<caption>営団地下鉄と乗り入れ路線</caption>
<thead>
<tr><th>路線名</th><th>乗り入れ路線</th><th>乗り入れ先</th></tr>
</thead>
<tbody>
<tr><td rowspan="2" nowrap="nowrap">日比谷線</td><td nowrap="nowrap">東武伊勢崎線</td><td>北千住から東武動物公園</td></tr>
<tr><td nowrap="nowrap">東急東横線</td><td>中目黒から菊名</td></tr>
<tr><td rowspan="3" nowrap="nowrap">東西線</td><td nowrap="nowrap">JR 中央線</td><td>中野から三鷹</td></tr>
<tr><td nowrap="nowrap">JR 総武線</td><td>西船橋から津田沼</td></tr>
<tr><td nowrap="nowrap">東葉高速線</td><td>西船橋から東葉勝田台</td></tr>
<tr><td rowspan="2" nowrap="nowrap">千代田線</td><td nowrap="nowrap">JR 常磐線</td><td>綾瀬から取手</td></tr>
<tr><td nowrap="nowrap">小田急線</td><td>代々木上原から本厚木</td></tr>
<tr><td rowspan="2" nowrap="nowrap">有楽町線</td><td nowrap="nowrap">東武東上線</td><td>和光市から森林公園</td></tr>
<tr><td nowrap="nowrap">西武有楽町線経由池袋線</td><td>小竹向原から飯能</td></tr>
<tr><td nowrap="nowrap">半蔵門線</td><td nowrap="nowrap">東急田園都市線</td><td>渋谷から中央林間</td></tr>
<tr><td rowspan="2" nowrap="nowrap">南北線</td><td nowrap="nowrap">東急目黒線</td><td>目黒から武蔵小杉</td></tr>
<tr><td nowrap="nowrap">埼玉高速鉄道線</td><td>赤羽岩淵から浦和美園</td></tr>
</tbody>
</table>

name 属性と id 属性

 XHTML 1.0 では,HTML 4 において aappletformframeiframeimgmap 要素の name 属性の役割は,id 属性が担うこととなり,name 属性を使うことは推奨されない。

 Section 6 で改めて述べるが,従来の HTML UA との互換性を保つためには,ひとつの要素に対して name 属性と id 属性とに同じ値を与えておけばよい。