DOCUMENT

body 要素 (HTML)

[5] HTMLbody 要素型の要素は、 文書の本体 (本文) を表します。文書に丁度1つだけ存在します。

[6] 仕様書:

[4]

局所名
body
名前空間名
http://www.w3.org/1999/xhtml
開始タグ
省略可能 (HTML 4), 必須 (XHTML 1)
終了タグ
省略可能 (HTML 4), 必須 (XHTML 1)
内容模型
(%block | script)+ +(ins | del) (HTML 4 厳密)
出現できる文脈
html の第2子要素として。 または frameset の子供たる noframes の子供として。

属性

[23] body 要素属性
alinkcolor(自動)選択リンク文字色[HTML4] 非推奨, [XHTML1]
xfa:APIVersionAcrobat:6.0.0 など生成ソフトウェア名・版Adobe 規格PDF
backgroundURI(なし)背景画像[HTML4] 非推奨, [XHTML1]
bgcolorcolor(自動)背景色[HTML4] 非推奨, [XHTML1]
bgproperties背景表現非標準WinIE
bottommargin下余白非標準WinIE
xfa:contentTypetext/html 固定Adobe 規格PDF
fgcolor
leftmargin左余白非標準WinIE
linkcolor(自動)未訪リンク文字色[HTML4] 非推奨, [XHTML1]
nowrap自動折返しなし非標準
rightmargin右余白非標準WinIE
xfa:spec2.0.2 などXFA の版Adobe 規格PDF
textcolor(自動)文字色[HTML4] 非推奨, [XHTML1]
tracingopacity非標準Dreamweaver 4.0
tracingsrc非標準Dreamweaver 4.0
vlinkcolor(自動)既訪リンク文字色[HTML4] 非推奨, [XHTML1]
xmlns:xfahttp://www.xfa.org/schema/xfa-data/1.0/名前空間名Adobe 規格PDF TABLE 8.64

実装

[1] NN 1.2 より前には animated title のように body 要素の開始タグを何個も書くことで背景色がどんどん変えられる不具合があったらしいです。

[7] 簡単な body の例 RFC 1866 5.3.

<BODY>
<h1>Important Stuff</h1>
<p>Explanation about important stuff...
</BODY>

[8] IEは上パディングと上マージンで相殺を行っているみたい:メモランダム (2007-08-04 03:44:15 +09:00 版) http://mynotes.jp/blog/2007/08/ie_collapses_padding_and_margin (名無しさん)

[9] body 要素の最初の内包要素に上マージンがある場合の body 要素デフォルトのマージン処理 - 2xup.org (Taichi Kaminogoya 著, 2007-08-01 18:13:03 +09:00 版) http://2xup.org/log/2007/07/31-2030 (名無しさん 2007-08-04 02:16:46 +00:00)

[10] body直下要素に上マージン:メモランダム (2007-08-04 03:44:15 +09:00 版) http://mynotes.jp/blog/2007/07/margin-top_on_element_under_body (名無しさん 2007-08-04 03:48:22 +00:00)

[11] body直下要素に上マージン その2:メモランダム (2007-08-04 03:44:15 +09:00 版) http://mynotes.jp/blog/2007/08/margin-top_on_element_under_body2 (名無しさん)

[12] IEは上パディングと上マージンで相殺を行っているみたい:メモランダム ( 版) http://mynotes.jp/blog/2007/08/ie_collapses_padding_and_margin

[17] IEヘルプより:

<BODY helptype="topic" helpurl="mshelp://windows/?id=8f2c3a40-b8f6-46b7-b5f9-13c99ed70b2c" helpsource="online" helptopictype="tutorial" LANG="ja">

歴史

[2] JIS X 4151‐1992 参考3 4.2.1 の例で「本体」を表す body 要素型が登場してます。

body の誕生

[47] HTML要素概説
要素名
body
日付
説明
付の Dan Connolly の HTML DTD には body が含まれている。 body の初出と思われる。 前月の DTD までは section だったが、最外のみ body に改められ、入れ子で使うことはできなくなった。
説明
body の導入の理由は混合内容を避けるためと説明されている。 当時の HTML は現在の html, head, body がなく、 headbody の内容をそのまま書くだけの単純なものだった。 しかし title などを文書の先頭に1回だけ書くという制約を付けつつ、 本文の要素や文字列は自由に書けるという条件を SGML DTD では記述できなかった。そこで body を導入し開始タグ終了タグを省略可能とすることで、 これまで通りの文書の書き方を認めつつ SGML DTD で記述できるようにしたのである。 要素名は何でも良かったのであり、もうしばらく試行錯誤が続く。
[43] HTML要素概説
要素名
body
要素名
document
要素名
heading
要素名
header
日付
説明
Dan Connolly電子メールは、 DTD 起草にあたり文書の「body」の大部分を含める document 要素を新設することとし、 代案として document ではなく body と名付け、現在の head に当たる heading を導入することも提案した。 >>45
説明
対する同じ日の Tim Berners-Lee の返信は、後者案を良しとした。 >>46 また、このとき編集されたと思われるウェブページでは、 後者案をもとに Header と Body と書いている。 (ただし Header は見出しであり、要素名は明らかでない。) >>44
出典

[13] Synchronized Multimedia Integration Language ( 版) http://www.w3.org/TR/1998/REC-smil-19980615/#body

[14] WordprocessingML要素型 w:body を使っています。

[48] HTML TADS deviations from standard HTML specifications, , https://www.tads.org/t3doc/doc/htmltads/deviate.htm#deviations

BODY 要素 (DjVu XML)

[273] DjVu XML には HTMLbody 要素から派生した BODY 要素がありました。

[15] [whatwg] Specification unclear about how HTMLElement.prototype.onscroll's getter/setter should behave for "body" elements ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-December/038221.html

[16] body 終了タグは、 <marquee></body>, <svg><foreignobject></body> のような場合や、 innerHTML の場合 (html 以外) には無視されます。

[3] XEP-0071: XHTML-IM ( 版) http://www.xmpp.org/extensions/xep-0071.html#wrapper

The root element for including XHTML content within XMPP stanzas is <html/>. This element is qualified by the 'http://jabber.org/protocol/xhtml-im' namespace. From the perspective of XMPP, the wrapper element functions as an XMPP extension element; from the perspective of XHTML, it functions as a wrapper for XHTML 1.0 content qualified by the 'http://www.w3.org/1999/xhtml' namespace. Such XHTML content MUST be contained in one or more <body/> elements qualified by the 'http://www.w3.org/1999/xhtml' namespace and MUST conform to the XHTML-IM Integration Set defined in the following section. If more than one <body/> element is included in the <html/> wrapper element, each <body/> element MUST possess an 'xml:lang' attribute with a distinct value, where the value of that attribute MUST adhere to the rules defined in RFC 5646 [18].

[18] Remove <iframe seamless> · whatwg/html@1490eba ( 版) https://github.com/whatwg/html/commit/1490eba4dba5ab476f0981443a86c01acae01311

[19] 民泊のエアビーアンドビー、苦情サイト新設 - WSJ ( (NATHAN OLIVAREZ-GILES著, )) http://jp.wsj.com/articles/SB10513819889225894892604582103810164964978

<body

id="article_body"

class="pageFrame subType-unsubscribed edition-japan logged-out"

intent

in-width="*"

in-interaction="*"

itemscope

itemtype="//schema.org/NewsArticle">

[20] Fix typo: remove a 'not' in body fills the viewport quirk (zcorpan著, ) https://github.com/whatwg/quirks/commit/0e348be84e29e4fd1812128d6ca85f3b247e5dfc

[21] Editorial: Cross-reference DOM "child" where appropriate in rendering (zcorpan著, ) https://github.com/whatwg/html/commit/e8c91c05edc8d6cdb33fdd5452e052359d40490b

[22] Editorial: add a note about the 'document's body element' (zcorpan著, ) https://github.com/whatwg/quirks/commit/c82f966a8de5be77879a7c8a1b314925cee3b566

[24] [css-overflow] body overflow propagation is less defined than it was in CSS 2.1 · Issue #1905 · w3c/csswg-drafts () https://github.com/w3c/csswg-drafts/issues/1905

[25] Restrict the main element to be used once per document (annevk著, ) https://github.com/whatwg/html/commit/1dec930b3df93c799d5f3f685a46940913476086

[26] Restrict the main element to be used once per document by annevk · Pull Request #3354 · whatwg/html () https://github.com/whatwg/html/pull/3354

[27] update <body> mappings / issue #117 (jasonkiss著, ) https://github.com/w3c/html-aam/commit/724677bc4d14eefb30b207ab5f580a85477a0b19

[28] Body element likely should not map to ARIA document role · Issue #117 · w3c/html-aam () https://github.com/w3c/html-aam/issues/117

[29] leverage CORE mappings / issue #119 (jasonkiss著, ) https://github.com/w3c/html-aam/commit/a1a661d9874e2674cd99b7dda1cf6962dc91df1b

[30] Should header, footer have "Use WAI-ARIA mapping" when scoped to the body element? · Issue #119 · w3c/html-aam () https://github.com/w3c/html-aam/issues/119

[31] update <body> mappings / issue #117 (jasonkiss著, ) https://github.com/w3c/html-aam/commit/724677bc4d14eefb30b207ab5f580a85477a0b19

[32] Body element likely should not map to ARIA document role · Issue #117 · w3c/html-aam () https://github.com/w3c/html-aam/issues/117

[33] leverage CORE mappings / issue #119 (jasonkiss著, ) https://github.com/w3c/html-aam/commit/a1a661d9874e2674cd99b7dda1cf6962dc91df1b

[34] Body Margin 8px | Miriam Eric Suzanne, https://www.miriamsuzanne.com/2022/07/04/body-margin-8px/

[35] >>34 CSS の起源までたどり着いて 「Final answer」 だとしちゃってるのは残念。 なんで 8px なの? って疑問に答えるにはもう一頑張りしないといけなかった。

[36] ncsa-mosaic/HTML.c at 29c82be0c24dcf08125d3fe289b61ea9f1832bbf · alandipert/ncsa-mosaic · GitHub, https://github.com/alandipert/ncsa-mosaic/blob/29c82be0c24dcf08125d3fe289b61ea9f1832bbf/libhtmlw/HTML.c#L68

[37] GitHub で公開されている NCSA Mosaicソースコード >>36 みると、今で言う margin-left, margin-top20 という値になっています。これがいつからこの値なのかわかりませんし、 このソースコードがすべてのプラットフォームで使われていたのかもわかりませんし、 20 の単位が px なのかもわかりませんけど...

[38] File:NCSA Mosaic Browser Screenshot.png - Wikimedia Commons, , https://commons.wikimedia.org/wiki/File:NCSA_Mosaic_Browser_Screenshot.png

[39] それで試しに NCSA Mosaicスクリーンショットを探してみると、 確かに 20px くらい空いてそうな感じがしますね。例えば >>38。 他にもいくつか出てきますけど、どれも今の Webブラウザーよりずっと余白が大きい。 文字の大きさと比べればよくわかります。

[40] Mosaic Netscape 0.9 になると margin-left は半角1文字分くらいになってますね。 margin-top はいまいちはっきりしないスクリーンショットが多いのですけど、 Netscape Navigator 1.0 のスクリーンショットだと margin-top も半角1文字分くらいになってたみたいで。

Mosaic もその時代に margin が小さくなっていたのか、それとも Netscape が小さな値を選んだのか、気になりますね。 スクリーンショットで調べるのは限界があるので、 当時の環境を再現して調べてみたいものです。

[41] Line Mode Browser がどうしていたのかはよくわからないなあ。 bodymargin/padding はほぼなくて hnp とで margin-left が違うようにも見えなくもないけど、 スクリーンショットがいまいち信用できない (近年のエミュレーションも混じってる & 画面端がどこかよくわからない) し、 どんな HTML を解釈した結果なのかがわからないと断言しづらい。

[42] WorldWideWeb もようわからんなあ。。。 まあ WWW は Mosaic の仕様には直接影響していないのだろうけど。