text/html

text/html (MIME 型)

[1] text/html (HTML MIME型 (HTML MIME type) ) は、 HTML文書MIME型です。 text/html文書のことを、 HTML文書といいます。

[47] text/html は、Web で最もよく用いられているマーク付け言語である HTML で使われる、おそらく Web で最もよく用いられている MIME型です。

仕様書

構文

[43] MIME型 text/html で識別されるファイルの内容は、 HTML文書です。つまり HTML構文に従って記述されている文書 (であると期待されるもの) です。 HTML構文解析器によって解釈されます。

HTML構文に従っていない text/html文書も数多く存在しますが、 それらも含めてどう解釈するか HTML構文解析器の動作が HTML Standard により規定されています。

引数

[39] 必須のパラメーターはありませんが、 charset パラメーターを指定することが極めて望ましいでしょう。

x-type パラメーター

[38] "x-type" パラメーターは namazu で内部処理に使われています。 値 "mhonarc" は、 mhonarc で生成された HTML 文書をあらわします。

charset パラメーター

[7] RFC1866 以降では MIMEcharsetパラメーター同様に規定しています。 既定値は転送プロトコルに依存し、 MIME では US-ASCII, HTTP では ISO-8859-1 です。

[40] 古い draft では、この charset パラメーターの指定を元に SGML宣言文書文字集合を書き換えることが検討されていました。 (HTML and MIME http://www.w3.org/MarkUp/1995-archive/AndMIME.html)

[41] HTML4 では、利用者エージェントが既定値を補うことを禁止しています。文字符号化の決定は、 (1) charset 引数 (2) meta 要素を使った Content-Typecharset 引数 (3) 呼び出し元に charset 属性があれば、その値を使います。これに加えて、学習や利用者指定の既定値を使っても構いません。 IW:HTML4:charset.html#spec-char-encoding 参照。

level パラメーター

[42] level 引数は、 HTML の実装水準を指定します。 HTML 2.0 (RFC 1866) では 12 が指定出来、 2 が既定値でした。

version パラメーター

[4] HTML の版を指定するパラメーターで、提案→削除→復活を繰り返しています。 HTML and MIME http://www.w3.org/MarkUp/1995-archive/AndMIME.html では文書型宣言中の公共識別子にある版番号を指定、と書いてありますから、 2.0 のような値を入れるのでしょうか。

[5] 最終版 HTML 2.0 (RFC 1866) にはこのパラメーターは規定されていません。

[51] 次のような値が使われることがあります。

 text/html; version=2.0
 text/html; version=3.2
 text/html; version=4.0
 text/html; version=4.01
 text/html; version=5

拡張子

[45] 拡張子には .html.htm がよく用いられます。

XHTML との関係

[6] XHTMLapplication/xhtml+xml を使います。 歴史的には text/html を使って送られていたこともありましたが、 現在では HTMLtext/htmlXHTMLapplication/xhtml+xml と明確に分けられています。

XHTML も参照。

派生言語の MIME 型

[53] HTML から派生した言語text/html を使うのは不適切です。

[54] それぞれの MIME型が定義されていたり、利用されていたりすることもあります。 例えば次のようなものがあります。

[55] HTML 派生言語の MIME型

歴史

text/x-html

[52] 当初、たまに text/x-html が使われたこともありました。

text/html 媒体型と文書型宣言の補完

[15] 素のSGML では文書型宣言は必須であるにも拘らず、 HTML 文書の文書型宣言は歴史的に省略されてきました。 HTML UA は普通 SGML 解析器ではないので、文書型宣言は存在意義がなかったのです。

この点において SGML との整合性のために、 初期の HTML 仕様では MIME の媒体型指定が文書型宣言を暗示しているとこじつけています。

  • [16] HTML3.0 draft では、 <!doctype HTML public "-//W3O//DTD W3 HTML 3.0//EN"> で文書を始めることを推奨しつつも、 text/html; version=3.0 であればこの文書型宣言を暗示するとされています (The Structure of HTML 3.0 Documents 参照)。

XHTML と text/html

[9] XHTML1.0 は、附属書 C の互換性の手引きに従った XHTML 文書は text/html としても良いとしています。

XHTML Media Types http://www.w3.org/TR/xhtml-media-types/ (W3C Note) は、 XHTML 1.0 は互換性の手引きに従っていれば text/html にしてもよく、従っていない場合やそれ以外の XHTML では application/xhtml+xml などを使うべきとしています。

[10] 実際には、 1.0 以外の XHTML1 や互換性の手引きに従っていないものにも text/html が使われています。これは、 application/xhtml+xmlIE が未だに対応していないことなどによるものです。

私見では、 1.0 以外の XHTML 1 であっても、 互換性の手引きに従っていて、実際 NET などを除いて HTML4 と互換であると著者が判断したのであれば text/html と札付けしても問題ないと思います。

(ほとんど違いのない XHTML 1.0 Strict ではよくて、 XHTML 1.1 では駄目というのは不条理でしょう。 usemap 属性などの一部の非互換なものを使っていない限りは。)

[19] Sending XHTML as text/html Considered Harmful http://www.hixie.ch/advocacy/xhtml

Ian Hickson の XHTML を text/html で送るなという話。

Web Forms 2.0 で XHTML 版を text/html で送るなとくどく書かれているのはこういう訳か。 (名無しさん)

[20] Re: Sniffing XHTML sent as text/html from Steven Pemberton on 2000-09-13 (www-html@w3.org from September 2000) http://lists.w3.org/Archives/Public/www-html/2000Sep/0024.html

W3C HTML WG は、 text/html で送られた XHTML 文書HTML として解釈するべきであるとの見解。 (名無しさん [sage])

[21] HTML Working Group Voyager Issue Tracking System - XHTML-1.0/6232 http://hades.mn.aptest.com/cgi-bin/voyager-issues/XHTML-1.0?id=6232;expression=appendix%20c;user=guest

互換性指針のいくつかの問題について、 W3C HTML WGは直す意思が無いらしい。 (名無しさん [sage])

[22] h3h.net &#187; Blog Archive &#187; Sending XHTML as text/html Considered Harmful to Feelings http://h3h.net/2005/12/xhtml-harmful-to-feelings/ (名無しさん)

[23] Bug 1500 - XHTML-sent-as-text/html is parsed as XML http://www.w3.org/Bugs/Public/show_bug.cgi?id=1500 (名無しさん)

[24] Google Desktoptext/html で、 文書型宣言XHTML 1.0DTD参照しておりますが、かなりひどい tag soup です。空要素タグ開始タグと同じだとかいうレベルではなく、 属性値引用符で囲まれていないとか、 非妥当属性が使われているとか。

(名無しさん 2007-02-26 12:40:20 +00:00)

[25] TAG telcon -- 19 Mar 2007 (2007-03-20 02:29:14 +09:00 版) http://www.w3.org/2007/03/19-tagmem-minutes.html#item04 (名無しさん 2007-03-20 01:52:07 +00:00)

[26] XHTML Basic 1.1:

xhtml-basic/Overview.mhtml - diff - 1.21.2.61 (2007-03-26 16:53:21 +09:00 版) http://htmlwg.mn.aptest.com/viewcvs/viewcvs.cgi/xhtml-basic/Overview.mhtml.diff?r1=1.21.2.60&r2=1.21.2.61&sortby=date&only_with_tag=r1_1

Changed media type as per meeting on 21 March 2007.

元に戻りました。 (名無しさん 2007-03-26 07:55:54 +00:00)

[27] XHTML Basic 1.1:

xhtml-basic/Overview.mhtml - diff - 1.21.2.61 (2007-03-26 16:53:21 +09:00 版) http://htmlwg.mn.aptest.com/viewcvs/viewcvs.cgi/xhtml-basic/Overview.mhtml.diff?r1=1.21.2.60&r2=1.21.2.61&sortby=date&only_with_tag=r1_1

Changed media type as per meeting on 21 March 2007.

元に戻りました。 (名無しさん 2007-03-26 07:56:13 +00:00)

[28] >>27 いまのところ XHTML 1.1 はそのままのようです。。。 (名無しさん 2007-03-26 08:08:34 +00:00)

[29] FW: Agenda: HTML media type (Grosso, Paul 著, 2007-02-16 23:52:17 +09:00 版) http://lists.w3.org/Archives/Public/public-xml-core-wg/2007Feb/0016.html (名無しさん)

[30] Re: [XHTML1.1] Error in Conformance Definition document? (Shane McCarron 著, 2007-04-02 22:16:44 +09:00 版) http://lists.w3.org/Archives/Public/www-html/2007Apr/0015.html

To short circuit it, this was my editorial error.

(名無しさん 2007-04-03 12:55:59 +00:00)

[31] Geoffers’ &#187; Why XHTML As text/html Is Evil (2007-04-08 12:36:21 +09:00 版) http://geoffers.uni.cc/archives/2007/04/07/why-xhtml-as-texthtml-is-evil/ (名無しさん 2007-04-08 03:37:17 +00:00)

[32] 「XHTML文書」を text/html として認識させるべからず @ ぽかぽかWeb研究室 (2007-04-28 12:35:35 +09:00 版) http://yupotan.sppd.ne.jp/web/html-xhtml.html (名無しさん)

[33] Re: XHTML 1.1 (Feb 2007 WD) as text/html? (Mark Birbeck 著, 版) http://lists.w3.org/Archives/Public/public-xhtml2/2007Oct/0011.html

やれやれ。

RFC 1866 (HTML 2.0) 4. HTML as an Internet Media Type

An HTML user agent allows users to interact with resources which have HTML representations. At a minimum, it must allow users to examine and navigate the content of HTML level 1 documents. HTML user agents should be able to preserve all formatting distinctions represented in an HTML document, and be able to simultaneously present resources referred to by IMG elements (they may ignore some formatting distinctions or IMG resources at the request of the user). Level 2 HTML user agents should support form entry and submission.

HTML user agentは利用者が HTML 表現を持つ資源と相互作用することを可能とします。 少なくても、user agentは利用者が HTML level 1 文書の内容を検査し案内することを可能としなければなりません。 HTML user agentは HTML 文書中に表現されている全ての整形上の差異を保持し、 同時に IMG 要素が参照している資源を表現することが出来るべきです (UA は利用者の要求で整形上の差異や IMG 資源を無視しても構いません)。level 2 HTML user agentform 項目及びsubmissionに対応するべきです。

4.1. text/html media type

This specification defines the Internet Media Type [IMEDIA] (formerly referred to as the Content Type [MIME]) called `text/html'. The following is to be registered with [IANA].

この仕様書は text/html というInternet Media Type (かつてはcontent typeと呼ばれていたもの。) を定義します。次を IANA に登録します。

Media Type name
text
Media subtype name
html
Required parameters
none
Optional parameters
level, charset
Encoding considerations
any encoding is allowed
Security considerations
see 10, "Security Considerations"

The optional parameters are defined as follows:

省略可能parameterは次の通り定義します。

Level

The level parameter specifies the feature set used in the document. The level is an integer number, implying that any features of same or lower level may be present in the document. Level 1 is all features defined in this specification except those that require the <FORM> element. Level 2 includes form processing. Level 2 is the default.

level parameterはこの文書で使われている機能の集合を指定します。 level は1つの整数で、 文書中にはその数値以下のlevelの機能が出現し得ます。 level 1 はこの仕様書で定義された機能のうち <FORM> elementを必要とする物を除く全ての機能です。 level 2 はform処理を含みます。 level 2 が既定値です。

Charset

The charset parameter (as defined in section 7.1.1 of RFC 1521[MIME]) may be given to specify the character encoding scheme used to represent the HTML document as a sequence of octets. The default value is outside the scope of this specification; but for example, the default is `US-ASCII' in the context of MIME mail, and `ISO-8859-1' in the context of HTTP [HTTP].

charset parameterは (RFC1521 の7.1.1節で定義された通り)、オクテットの連続として HTML 文書を表現するのに使う文字符号化方式を指定します。 既定値はこの仕様書の適用範囲外です。しかし例えば、 MIME mailの文脈では既定値は US-ASCII ですし、 HTTP の文脈では ISO-8859-1 です。

4.2. HTML Document Representation HTML 文書表現

A message entity with a content type of `text/html' represents an HTML document, consisting of a single text entity. The `charset' parameter (whether implicit or explicit) identifies a character encoding scheme. The text entity consists of the characters determined by this character encoding scheme and the octets of the body of the message entity. content typetext/htmlmessageentityは一つのtext entityで構成される HTML 文書を表します。 charset parameterは (暗示であれ明示であれ) 文字符号化方式を識別します。 この文字符号化方式で決定される文字とmessageentitybodyのオクテットでtext entityは構成されます。

4.2.1. Undeclared Markup Error Handling 未宣言markuperrorの取扱い

To facilitate experimentation and interoperability between implementations of various versions of HTML, the installed base of HTML user agents supports a superset of the HTML 2.0 language by reducing it to HTML 2.0: markup in the form of a start-tag or end-tag, whose generic identifier is not declared is mapped to nothing during tokenization. Undeclared attributes are treated similarly. The entire attribute specification of an unknown attribute (i.e., the unknown attribute and its value, if any) should be ignored. On the other hand, references to undeclared entities should be treated as data characters.

For example:

    <div class=chapter><h1>foo</h1><p>...</div>
      => <H1>,"foo",</H1>,<P>,"..."
    xxx <P ID=z23> yyy
      => "xxx ",<P>," yyy
    Let &alpha; &amp; &beta; be finite sets.
      => "Let &alpha; & &beta; be finite sets."

Support for notifying the user of such errors is encouraged.

Information providers are warned that this convention is not binding: unspecified behavior may result, as such markup does not conform to this specification.

4.2.2. Conventional Representation of Newlines 慣習的な改行の表現

SGML specifies that a text entity is a sequence of records, each beginning with a record start character and ending with a record end character (code positions 10 and 13 respectively) (section 7.6.1, "Record Boundaries" in [SGML]).

SGML はtext entityrecordの連続と規定しており、各recordrecord開始文字で始まりrecord終了文字で終わります。 両文字はそれぞれ符号位置 1013 です。 (SGML の7.6.1節「記録の境界」訳注: JIS X 4151-1992 では6.6.1 参照。)

[MIME] specifies that a body of type `text/*' is a sequence of lines, each terminated by CRLF, that is, octets 13, 10.

MIME はtype text/*bodyを行の連続と規定しており、それぞれは CRLF, つまりオクテット 13 及び 10 で終端されます。

In practice, HTML documents are frequently represented and transmitted using an end of line convention that depends on the conventions of the source of the document; frequently, that representation consists of CR only, LF only, or a CR LF sequence. Hence the decoding of the octets will often result in a text entity with some missing record start and record end characters.

実際には、 HTML 文書は文書の出典の環境に依存した行末記法を使ってよく表現されます。 それは CR だけであったり LF だけであったり CR LF であったりします。 従ってオクテットの復号の時にtext entityrecord開始やrecord終了の文字が欠けていることがよくあります。

Since there is no ambiguity, HTML user agents are encouraged to infer the missing record start and end characters.

曖昧さはありませんから、 HTML user agentは欠けたrecord開始・終了両文字を推測することを推奨します。

An HTML user agent should treat end of line in any of its variations as a word space in all contexts except preformatted text. Within preformatted text, an HTML user agent should treat any of the three common representations of end-of-line as starting a new line.

HTML user agentは整形済みtextを除く全ての場面において、 全ての種類の行末を語間隔として取扱うのが良いです。 整形済みtext中では、 HTML user agentは3つの行末のよく使われる表現を新しい行の開始として取扱うのが良いです。

HTML 4

[17] HTML 4 は、 IW:HTML4:conform.html#text-htmltext/html を定義しています。

それによれば、引数は charset (省略可能、指定することを推奨) だけ、 内容転送符号化には任意のものを使用できます。

[18] 重要なことに、一般に HTTP では charset 引数の既定値は ISO-8859-1 ですが、 実際にはちゃんとなってないことが多いから HTML利用者エージェントは既定値を仮定してはならないとされています。 IW:HTML4:charset.html#spec-char-encoding

[14] XHTML 1.0: The Extensible HyperText Markup Language (Second Edition) : 5.1. Internet Media Type http://www.w3.org/TR/xhtml1/#media は、

XHTML Documents which follow the guidelines set forth in Appendix C, "HTML Compatibility Guidelines" may be labeled with the Internet Media Type "text/html" [RFC2854], as they are compatible with most HTML browsers.

附属書 C 『HTML互換性指針』に示した指針に従った XHTML 文書は、ほとんどの HTML ブラウザと互換ですから、Internet Media Type text/html で札付けしても構いません (may)。

[46] XHTML2 Working Group Teleconference -- 31 Mar 2010 ( 版) http://www.w3.org/2010/03/31-xhtml-minutes

[34] HTML5 Revision Tracker ( 版) http://html5.org/tools/web-apps-tracker?from=5013&to=5014

[35] [ietf-types] Update to text/html registration ( ( 版)) http://www.ietf.org/mail-archive/web/ietf-types/current/msg01708.html

[36] (X)HTML5 Tracking ( 版) http://html5.org/tools/web-apps-tracker?from=3551&to=3552

[3] Bug 8321 – change controller for HTML media type ( 版) http://www.w3.org/Bugs/Public/show_bug.cgi?id=8321#c17

[37] Web Applications 1.0 r3552 Include MIME type registration sections. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=3551&to=3552

[2] (X)HTML5 Tracking ( 版) http://html5.org/tools/web-apps-tracker?from=4458&to=4459

[49] (X)HTML5 Tracking ( 版) http://html5.org/tools/web-apps-tracker?from=4580&to=4581

[50] Let [MIMESNIFF] define MIME-related concepts (domenic著, ) https://github.com/whatwg/html/commit/0d08aea0733e5ad21f15f626b64d413a8c447083

[56] 18338 – Registries (IANA): text/html MIME type definition should require that charset="" value be valid and correct () https://www.w3.org/Bugs/Public/show_bug.cgi?id=18338

[57] HTTP::Headers - search.cpan.org () http://search.cpan.org/~oalders/HTTP-Message-6.13/lib/HTTP/Headers.pm

Content_Type => 'text/html; version=3.2',

[58] Require utf-8 when specifying character encoding by sideshowbarker · Pull Request #3091 · whatwg/html () https://github.com/whatwg/html/pull/3091

[59] Editorial: use HTML/XML MIME type terms (annevk著, ) https://github.com/whatwg/xhr/commit/daa0baea431703640e1d35fde8db8cd5050f578b

[60] Use "XML MIME type" · Issue #160 · whatwg/xhr () https://github.com/whatwg/xhr/issues/160

[61] Editorial: use HTML/XML MIME type terms by annevk · Pull Request #171 · whatwg/xhr () https://github.com/whatwg/xhr/pull/171

[62] Define a new MIME type model, parser, and serializer (annevk著, ) https://github.com/whatwg/mimesniff/commit/cc81ec48288944562c4554069da1d74a71e199fb

[63] Editorial: tweak MIME type group definitions (domenic著, ) https://github.com/whatwg/mimesniff/commit/452938939d1d88e3c74f59f41f14579249130437

[64] Editorial: tweak MIME type group definitions by domenic · Pull Request #59 · whatwg/mimesniff () https://github.com/whatwg/mimesniff/pull/59

[66] CORB: protecting certain nosniff and 206 responses (anforowicz著, ) https://github.com/whatwg/fetch/commit/794dd5452705564538440cc5b2c1f13d909e2f9a