HTML document

HTML 構文

[9] HTML構文 (The HTML syntax) は、 HTML の構文の一種で、最もよく使われているものです。 HTML構文SGML 風の構文を持っていますが、 SGML部分集合でも超集合でもなく、 互換性はありません。

[10] HTML構文に対して、 XML を構文として採用したものを XHTML構文と呼びます。 XHTML構文は実際にはほとんど使われていません。

[12] DOM における Document には HTML文書 (HTML document) XML文書の2種類があります HTML5。両者は、元々どちらの構文で書かれていたかとおおむね一致します。

「おおむね」なのは、 DOM 上の操作で作られた Document も存在するからです。
ただし、両者を特に区別せずに「HTML文書」ということもあります (HTML5 仕様書の章節名自体がそうなっています)。

目次

  1. 仕様書
  2. 媒体型
  3. 構文
  4. 他の言語への HTML の埋め込み構文
  5. 特別な制約
  6. 構文解析
    1. 仕様書
    2. 刺激的な概念
    3. 構文解析器の構成要素
  7. 直列化
  8. その他の話題
  9. 非線形な変形
  10. 奇癖モード
  11. テキストファイルの DOM 構築
  12. 媒体文書とプラグイン文書、エラー文書
  13. 歴史
    1. SGML 時代
    2. Web Forms 2.0 HTML 構文の構文解析
    3. HTML5 仕様書による構文解析算法の明確化
  14. 実装
  15. メモ

仕様書#

媒体型#

[14] HTML文書 (HTML構文で記述された文書) は、媒体型 text/html として札付けしなければなりません HTML5

[15] 逆に、text/html札付けされた文書HTML構文として解釈されます HTML5

構文#

[189] HTML の構文

[98] 過去に HTML で用いられていたこともある構文には次のものがあります。

他の言語への HTML の埋め込み構文#

特別な制約#

[4] 文字符号化宣言については、文字参照を使ってはいけないことや先頭1024バイトに含まれないといけないことのような通常の要素と異なる制約があります。

[102] Pingback はその pingback 要素文字列表現に特別な制約を設けています。

構文解析#

[88] HTML構文解析器XML構文解析器に共通の事項に関しては、 構文解析器 (Web) を参照してください。

仕様書#

[52] >>50 では単独の文書としての構文解析が、>>51 では特定の Element の文脈や任意の Document の文脈での構文解析 (innerHTML) が規定されています。

刺激的な概念#

構文解析器の構成要素#

script nesting level
document.open から参照されます。
script-created parser
document.open で作られたかどうかを表します。
構文解析したテキスト
document.open から参照されます。 文書reload override buffer と同じかもしれません。 document.open を参照。

[170] document.write からHTML構文解析器が呼び出され、 script 要素挿入される場合、 利用者エージェント依存の方法でスクリプトを実行するか判断できることになっています。

script 参照。

直列化#

[190] HTMLの直列化参照。

その他の話題#

非線形な変形#

[77] HTML構文解析器は通常節点からへ、からへ、 属性から内容へと順にDOM木を構築していき、逆方向に進むことはありません。 しかし例外的に次のケースでは、それ以外の節点に変更が加えられることがあります。

[89] restart the parser が発動すると構文解析器のみならず navigate のレベルで処理が再起動されることがあります。

[78] 里親付けが発生すると、開いている table 要素として要素などが挿入されることがあります。

[79] AAA が発動すると、節点が移動することがあります。

[81] frameset-ok フラグが ok な状態で frameset 開始タグが現れると、 body 要素が削除されます。

[82] html 開始タグbody 開始タグは、2つ目以降であっても属性は (既に設定されていなければ) 無視されずに設定されます。

[86] head 終了タグより後で body 開始タグより前に現れた head 要素の中に現れる要素head 要素に挿入され、 body 終了タグより後に現れた子要素テキストbody 要素に挿入されます。 同じ位置でも空白注釈なら見かけ上の親要素に挿入されますから、 空白注釈の後に子要素空白以外のテキストがあると、 DOM 上の順序が入れ替わります。更に body 要素に関しては、一度要素テキストが現れると body開いている要素のスタックに戻されるので、 その後現れた注釈空白body 要素に追加されるようになります。

[84] 構文解析器の動作の途中で実行された script により、構文解析器の途中のDOM木は任意の形に変形されることがあります。 そのような変形があった後でも、構文解析器里親付けを除き、 DOM木の最新の状態ではなく構文解析直後の状態に基づき処理を進めていきます。

[85] 例えば構文解析の途中で script開いている要素のスタック上の要素を他の文書に移動すると、 以後構文解析が進んでいくと現れる要素はそちらの文書に挿入されていくことになります。

[90] スクリプトによって table 要素根要素となった状態で里親付けが発生すると、 要素テキストの挿入先が Document になり、 DOM の制限上挿入できないため、構文解析の結果が捨てられることとなります。 (捨てられる部分にスクリプトが含まれていると、文書挿入されないので、 実行もされません。)

奇癖モード#

[94] 奇癖モード限定奇癖モードには、 DOCTYPEスイッチによって切り替わります。

[91] 奇癖モードp 要素が開いている時に table 要素開始タグが現れても、 p 要素は閉じられず、 table 要素p 要素子孫となります。

[92] 現在の HTML Standard では、モードによって構文解析の動作が変わるのはこれだけです。

[93] 歴史的には注釈構文解析の方法が違っていたりしました。 詳しくは奇癖モードを参照してください。

[95] 構文解析の途中でスクリプトにより document.open が呼び出されると、 Document のモードが途中で変化することがあります。 しかし document.open構文解析器を停止させ、 新しい構文解析器で以後の document.write を処理します。ですから、一旦 DOCTYPEスイッチでモードが決まると、 その後モードが変わることはありません。

複数 DOCTYPE があっても、最初のもの以外は無視されます。

テキストファイルの DOM 構築#

[106] HTML構文解析器は、テキストファイルへの navigate でも使われます。

[107] HTML構文解析器は、 MIME型として text/html 以外を指定した時の document.open の処理でも使われます。

媒体文書とプラグイン文書、エラー文書#

[109] navigate における媒体文書プラグイン文書、エラー文書の生成では、 HTML構文解析器は使われませんが、それにほぼ相当する動作が行われます。

[110] 例えば AppCache選択アルゴリズムstop parsing が適宜呼び出されます。
[111] iframe srcdoc文書構文解析のように、 DOCTYPE はありませんが、無奇癖モードとして扱われるようです。

歴史#

SGML 時代#

[135] HTML 4 仕様書の制約に従う SGML文書。 HTML document。 https://www.w3.org/TR/html4/conform.html#didx-HTML_document

[136] ISO/IEC15445 に従って構造化された文書。 (ISO‐HTML http://purl.org/NET/ISO+IEC.15445/15445.html#DEFS 4.15 参照。)

Web Forms 2.0 HTML 構文の構文解析#

[1] Web Forms 2.0 は従来の HTMLXHTML の両方の構文を認めています。 この章では、 HTML 構文の構文解析について扱います。

[2] 仕様書:

[3] 誤り処理

Web Forms 2.0 は、 SGML で規定されない曖昧な場合にどう構文解析するか正確には規定しません。 利用者エージェントの実装者は、 既存の製品を逆工学し、適当な動作を模倣するべきですWF2 2.18

[5] Web Forms 2.0HTML 4 の拡張として定義されており、 その HTML 4SGML に基づいているので、 >>3 のように規定されているのだと思われます。 しかし、 Web Forms 2.0HTML 文書は一般に妥当SGML 文書ではありません (DTD がないので)。 誤っている文書>>4 のように処理するとして、 誤っていない文書をどう構文解析するのがいいのかは Web Forms 2.0 は (わざと) 曖昧にしています。

HTML5 仕様書による構文解析算法の明確化#

[137] Re: several messages about serialising HTML and related subjects (Ian Hickson <ian@...> 著, 2008-02-29 02:23:03 +09:00 版) http://permalink.gmane.org/gmane.org.w3c.whatwg.discuss/13371

[138] Re: several messages about the HTML syntax (Ian Hickson <ian@...> 著, 2008-03-02 23:02:07 +09:00 版) http://permalink.gmane.org/gmane.org.w3c.whatwg.discuss/13415

[139] Re: several messages about the tree construction stage of HTML parsing (Ian Hickson <ian@...> 著, 版) http://permalink.gmane.org/gmane.org.w3c.whatwg.discuss/13438

[8] [whatwg] HTML5 Parsing spec first draft ready ( 版) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2006-February/005807.html

[67] HTML5構文解析の仕様は既存の WebブラウザーHTML構文解析器逆工学したものでしたが、 既存の構文解析器は細部においては異なっていましたから、どの Webブラウザーとも完全には一致していませんでした。 そのためすべての主要 Webブラウザー構文解析器を書き直すことになりました。 この新世代の構文解析器は一般にHTML5構文解析器 (HTML5 parser) と呼ばれています。

[132] HTML5 では、HTML構文のことを HTML5 と呼んでいました。

[133] XHTML構文XHTML5 と呼ばれていました。

[11] HTML5 (構文) や XHTML5 は、どちらも HTML5 仕様書で定義されていました。 (紛らわしかったです。)

[134] HTML5 (と XHTML5) は、 HTML5 仕様書HTML Standard となった時、 HTML (と XHTML) に改称されました。

実装#

[76] IE9svg 開始タグを正しく処理できますが、 math 開始タグは未知の HTML 開始タグとみなすようです。

メモ#

[203] Software Reuse Libraries with Mosaic, , https://web.archive.org/web/20010617160658/http://archive.ncsa.uiuc.edu/SDG/IT94/Proceedings/DDay/werkman/www94.html

[204] >>203 今のWebブラウザーではほぼ全文が謎に斜体で表示される。

ソースを見ると Abstract の <p> の前に <cite> があって、 Abstract 本体の後に </cite> がある。

Abstract だけを斜体にしたかったのだろう。当時の Webブラウザー (Mosaic かな?) では </cite>斜体が終わっていたらしい。今は p 要素が開いているところに </cite> があっても閉じられない。

[6] Tag Soup: How Mac IE 5 and Safari handle <x> <y> </x> </y> (Henri Sivonen 著, 2005-07-28 02:07:37 +09:00 版) http://hsivonen.iki.fi/soup-dom/

[7] Bug 311366 &#8211; should make custom elements able to contain blocks (<section>) ( 版) https://bugzilla.mozilla.org/show_bug.cgi?id=311366

[19] IRC logs: freenode / #whatwg / 20090813 ( 版) http://krijnhoetmer.nl/irc-logs/whatwg/20090813#l-171

[20] IRC logs: freenode / #whatwg / 20100324 ( 版) http://krijnhoetmer.nl/irc-logs/whatwg/20100324

[21] Notes on HTML5 Parser History — Anne’s Weblog ( 版) http://annevankesteren.nl/2010/05/html5-parser-history

[22] [webkit-dev] HTML5 tokenizer landing soon ( 版) https://lists.webkit.org/pipermail/webkit-dev/2010-June/013244.html

[23] IRC logs: freenode / #whatwg / 20100727 ( 版) http://krijnhoetmer.nl/irc-logs/whatwg/20100727#l-1210

[24] IRC logs: freenode / #whatwg / 20100805 ( 版) http://krijnhoetmer.nl/irc-logs/whatwg/20100805#l-303

[25] IRC logs: freenode / #whatwg / 20100913 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20100913#l-265

[26] IRC logs: freenode / #whatwg / 20100915 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20100915#l-454

[27] Web Applications 1.0 r5521 Parser foreign lands: Get rid of secondary insertion mode, always use 'in body', scope HTML in foreign lands so that we won't try to close elements cross-namespace (e.g. <svg><p><desc><form> won't imply a </p> that closes the <p>...; <td> won't close all the SVG if the SVG is in a cell).Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10314 ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5520&to=5521

[28] Web Applications 1.0 r5522 Parser foreign lands: Oops, I missed one of the ways that scoping happens.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10314 ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5521&to=5522

[29] Web Applications 1.0 r5563 Revamp how the foreign lands are defined to make it easier to add the U+0000 handling. This checkin should have no normative effect. If there are any normative changes in this patch, that's a bug, pleasel let me know ASAP.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=9659 ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5562&to=5563

[30] Web Applications 1.0 r5638 Add in some hard-coded limits for dealing with unclosed formatting elements to limit the explosive growth of the list of formatting elements in commonly-seen cases.Fixing http://www.w3.org/Bugs/Public/show_bug.cgi?id=10802 ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5637&to=5638

[31] Bug 10802 – Limit the number of identical items on the list of active formatting elements by removing previous duplicates when adding new items ( ( 版)) http://www.w3.org/Bugs/Public/show_bug.cgi?id=10802

[32] Bug 10801 – Limit the number of iterations in the loops in the AAA ( ( 版)) http://www.w3.org/Bugs/Public/show_bug.cgi?id=10801

[33] IRC logs: freenode / #whatwg / 20101021 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20101021

[35] Web Applications 1.0 r5920 Change how MathML and SVG are parsed in text/html: use a three-level tree constructor design instead of the two-level design we had before. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=5919&to=5920

[36] IRC logs: freenode / #whatwg / 20110203 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20110203#l-1313

[37] htmlparser: Summary ( ( 版)) http://hg.mozilla.org/projects/htmlparser/

[38] IRC logs: freenode / #whatwg / 20110608 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20110608

[39] IRC logs: freenode / #whatwg / 20110724 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20110724#l-388

[41] [whatwg] <!DOCTYPE html><body><table><math><mi>foo</mi></math></table> and other parser questions ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2011-December/034163.html

[42] Web Applications 1.0 r6870 Try to fix the problem David Flanagan raised a while back with the <!DOCTYPE html><body><table><math><mi>foo</mi></math></table> test case. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6869&to=6870

[43] IRC logs: freenode / #whatwg / 20120107 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20120107

[44] [whatwg] HTMLLinkElement.disabled and HTMLLinkElement.sheet behavior ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-January/034544.html

[45] [whatwg] document.write("\r"): the spec doesn't say how to handle it. ( ( 版)) http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2012-February/034867.html

[46] Web Applications 1.0 r6991 Rejig the wording of the character encoding section to make it more precise and in particular to not make CR processing require look-ahead. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=6990&to=6991

[47] [whatwg] A plea to Hixie to adopt <main>, and main element parsing behaviour ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2012-November/037828.html

[48] ( ( 版)) http://www.score.is.tsukuba.ac.jp/~minamide/papers/minamide-FM2012.pdf

[49] ( ( 版)) http://www.score.cs.tsukuba.ac.jp/~minamide/html5spec/model.html5

[53] [webkit-dev] Feature Announcement: Moving HTML Parser off the Main Thread ( ( 版)) http://lists.webkit.org/pipermail/webkit-dev/2013-January/023271.html

[54] HTML parser design - Google ドライブ ( 版) https://docs.google.com/a/google.com/drawings/d/1hwYyvkT7HFLAtTX_7LQp2lxA6LkaEWkXONmjtGCQjK0/edit

[55] Threaded HTML parser enabled on trunk - Google グループ ( ( 版)) https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/hBUVtg7gacE

[56] ChromeJavaScript の実行をドメインごとにブロックできますが、 ブロックまたはブロック解除の直後は JavaScript の実行のみオン・オフされ、HTML の構文解析器は従前のモードのままになります。ウィンドウを閉じて開き直すと完全に反映されます。 このため構文解析器は noscript の中身を解釈するのに JavaScript が実行されたり、その逆になったりします。

[57] Web Applications 1.0 r7999 Another very risky change! Please review! This attempts to refactor the parser logic so that the ownerDocument is explicitly set at each place a node is created by the parser. This actually fixes an ambiguity, which was what should happen when a script has transplated a node that is still on the stack of open elements into a Document without a browsing context, if the node created has some magic (e.g. <img src>, <script>). ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7998&to=7999

[58] Web Applications 1.0 r7998 Very risky editorial change! Please review! This attempts to refactor the parser logic so that the foster parenting is actually done inline in a single algorithm that is called by anywhere in the parser that could be affected by it. This will allow us to add the <template> magic with minimal actual magic in the prose, hopefully. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=7997&to=7998

[59] [whatwg] Namespaces and tag names in the HTML parser ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-July/039913.html

[60] [whatwg] Another issue in 12.2.5.5 parsing tokens in foreign content ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-July/040314.html

[61] Hixie's Natural Log: Tag Soup: How UAs handle <x> <y> </x> </y> ( ( 版)) http://ln.hixie.ch/?start=1037910467&count=1

[62] Streamable non-fatal non-conforming HTML parser error recovery strategy ( (Simon Pieters 著, 版)) http://lists.w3.org/Archives/Public/www-archive/2013Oct/0009.html

[64] Parsing (Windows) ( ( 版)) http://msdn.microsoft.com/en-us/library/ie/hh673554(v=vs.85).aspx

[65] [whatwg] Should ambiguous ampersand be a parse error? ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2014-January/041905.html

[66] Web Applications 1.0 r8554 Drop filterRes SVG attribute from the HTML parser, since it has fallen into disrepute. ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8553&to=8554

[72] IRC logs: freenode / #whatwg / 20140427 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20140427

[73] Web Applications 1.0 r8592 PARSER CHANGE: remove some attributes from the SVG attribute mapping ( ( 版)) http://html5.org/tools/web-apps-tracker?from=8591&to=8592

[74] nolanw/HTMLReader ( ( 版)) https://github.com/nolanw/HTMLReader

[75] IRC logs: freenode / #whatwg / 20140613 ( ( 版)) http://krijnhoetmer.nl/irc-logs/whatwg/20140613#l-683

[87] Flag HTML response as "HTML document". Set encoding also for XML. https:... · 572a6c6 · whatwg/xhr ( ( 版)) https://github.com/whatwg/xhr/commit/572a6c6c86562d31a217dac95d3e845ecc9a0fe4

[96] IRC logs: freenode / #whatwg / 20091112 ( 版) http://krijnhoetmer.nl/irc-logs/whatwg/20091112

[97] [whatwg] Parser-related philosophy ( ( 版)) http://lists.whatwg.org/pipermail/whatwg-whatwg.org/2013-July/040261.html

[99] Surfin' Safari - Blog Archive » The HTML5 Parsing Algorithm ( ( 版)) https://www.webkit.org/blog/1273/the-html5-parsing-algorithm/

[100] 886390 – Assigning to innerHTML on an SVG element should create elements in the SVG namespace ( ( 版)) https://bugzilla.mozilla.org/show_bug.cgi?id=886390

[101] Web Applications 1.0 r8856 Try to clarify stuff around fragment parsing (this removes the ability to call the fragment parsing algorithm without a context node; I couldn't find anyone doing that, but if I missed a case please let me know) ( ( 版)) https://html5.org/r/8856

[103] Web Applications 1.0 r8889 Clarify the handling of CRLF in HTML. ( 版) https://html5.org/r/8889

[104] Part1 - browsersec - Browser Security Handbook, part 1 - Browser Security Handbook - Google Project Hosting ( 版) https://code.google.com/p/browsersec/wiki/Part1#Hypertext_Markup_Language

[105] Ygg01/html5ever ( 版) https://github.com/Ygg01/html5ever

[112] Hixie's Natural Log: Tag Soup: Crazy parsing adventures http://ln.hixie.ch/?start=1137740632&count=1

おかしなHTML文書から各ブラウザが生成するDOMは奇々怪々。 (名無しさん 2006-01-21 04:09:31 +00:00)

[113] Editorial: synchronize with the DOM Standard · whatwg/html@21c6ec7 ( 版) https://github.com/whatwg/html/commit/21c6ec77594eb89b836d4872222f5916910967fd

[114] Formalize bogus comment state · whatwg/html@28a40d1 ( 版) https://github.com/whatwg/html/commit/28a40d193f38903bd328f4cf7fab460ad67058b3

[115] Fixup previous commit's MathML element references · whatwg/html@77c3dc4 ( 版) https://github.com/whatwg/html/commit/77c3dc4863a212cc944eede0e09907bec52cde43

[116] Formalize CDATA section state · whatwg/html@cbf837d ( 版) https://github.com/whatwg/html/commit/cbf837db2dab5eb68bab2204f1cefc7b64b2df75

[117] Fix #234: Change <menuitem> from void to like-<option> · whatwg/html@5e49a20 ( 版) https://github.com/whatwg/html/commit/5e49a20874fabef620bf7ea0be7534c73fbd58c4

[118] Editorial: define "reconsume" and avoid duplication of its steps · whatwg/html@d82b76d ( 版) https://github.com/whatwg/html/commit/d82b76dd6c1f87c3100126e87da8d66a6708b888

[119] [giow] (2) Make 'emit' always come after 'switch', and remove any men… · whatwg/html@1e5bf56 ( 版) https://github.com/whatwg/html/commit/1e5bf56f577ce924683470d595931865a197fb1f

[120] Remove <isindex> and <input name=isindex> · whatwg/html@5c44abc ( 版) https://github.com/whatwg/html/commit/5c44abc734eb483f9a7ec79da5844d2fe63d9c3b

[121] Add custom elements to HTML · whatwg/html@6e7eaa4 ( 版) https://github.com/whatwg/html/commit/6e7eaa4bd2912965fd83766f99f984f249531f3a

[122] Rust macros in html5ever ( ()) https://kmcallister.github.io/talks/rust/2014-rust-macros/slides.html

[123] Fix wording mistake in parsing a character reference ( (zcorpan著, )) https://github.com/whatwg/html/commit/918a56e5d1e9e86695770bf10c1893dd7bae6946

[124] Add examples for non-roundtrippable HTML ( (zcorpan著, )) https://github.com/whatwg/html/commit/970ef7eb56bdb1fa709b7b084818597a2b686bfa

[125] Allow dashes in comments (zcorpan著, ) https://github.com/whatwg/html/commit/518d16fdc672d1023dcfd2847d86f559d13a842f

[126] Allow comments to end with <!--> (zcorpan著, ) https://github.com/whatwg/html/commit/1633b9aadab815e6daba17950c4ff81a80b896ed

[127] Remove <menuitem> from Special category (nolanw著, ) https://github.com/whatwg/html/commit/7ecbcf1a037449c3d58e26ec704f5cb4cbdcf903

[128] Webブラウザー以外の (おそらく適当なパターンマッチしかしていない) ツールでは、 headbodyタグの省略すら正しく扱えない雑なものもあります。

[129] Simplify EOF handling in the parser (RReverser著, ) https://github.com/whatwg/html/commit/d2461df035aaccd4765a5ed6ea891f30303722d0

[130] Reconstruct active formatting elements for <menuitem> (zcorpan著, ) https://github.com/whatwg/html/commit/2999aa01438bdef11ba10aef82b775293efbef79

[131] Pass token instead of tag name to the adoption agency algorithm (zcorpan著, ) https://github.com/whatwg/html/commit/c3190514c682953f598f7d1df02f0ad16dc960ae

[140] Make document.write etc. throw during parsing custom elements (domenic著, ) https://github.com/whatwg/html/commit/00c6fa07bdb9f0d08a28f6c6e1ababca7d08618c

[141] Process custom element connectedCallback immediately during parsing (domenic著, ) https://github.com/whatwg/html/commit/ca818ee1c8458c3b862acd00d11779294cb89eea

[142] Don't serialize an extra LF in <pre>, <textarea>, <listing> (zcorpan著, ) https://github.com/whatwg/html/commit/2aa0000433f8c34263d29cee31bc95b1efdfef46

[143] Restore <xmp> to the "special" elements list (cscott著, ) https://github.com/whatwg/html/commit/00f25b32f60022329202825e87c3b82afbd55c16

[144] Web Applications 1.0 r6333 Move some of the quirky API requirements to DOM Core. ( 版) http://html5.org/tools/web-apps-tracker?from=6332&to=6333

[145] [cgiowt] (2) Reduce redundant parse errors in some edge cases involvi… (Hixie著, ) https://github.com/whatwg/html/commit/5e703c13ebbb94891511c4924ac36a45e6905e0f

[146] [cgiowt] (3) PARSER: Change whether <template><td></template> is a pa… (Hixie著, ) https://github.com/whatwg/html/commit/b29ecbe1b74218130ba5c82fa79a943a35f3daea

[147] [ct] (3) PARSER: apply r2806 fix to eof tokens as well (Hixie著, ) https://github.com/whatwg/html/commit/64037adb40c16b41a38699c48e9110e0dacc980c

[148] [cgiowt] (3) PARSER: when inlining the fake tags, I missed that <sele… (Hixie著, ) https://github.com/whatwg/html/commit/56a9a3f2e77092f6cf953b09b117217232e9d852

[149] [e] (0) Clean up some stuff in the 'in select' insertion mode (Hixie著, ) https://github.com/whatwg/html/commit/2e0d23dbd5a28b49aea0e14debbef481e3339d8b

[150] [giowct] (3) PARSER: Add a parse error for non-space characters in <t… (Hixie著, ) https://github.com/whatwg/html/commit/dab72ccea3b31bb74489358c6be5d7cc1cfe8ead

[151] [giowt] (3) PARSER: Only run the SVG script execution logic if a <scr… (Hixie著, ) https://github.com/whatwg/html/commit/7ae642f94e0c262d1f816b73f3fa23de8867d595

[152] [e] (0) PARSER: clarify what it means for there to be no 'adjusted cu… (Hixie著, ) https://github.com/whatwg/html/commit/6de16099bfe08c7bfe49fde6f1bc75189ba34582

[153] [cgiowt] (3) PARSER CHANGE: Change the Adoption Agency Algorithm so t… (Hixie著, ) https://github.com/whatwg/html/commit/ca405b3e4f1a7b6c5f50a12d6a8d144dbfdd7c25

[154] Remove obsolete permitted DOCTYPEs (sideshowbarker著, ) https://github.com/whatwg/html/commit/31c20af4913f997926b3c806e218d3d16a2944f2

[155] Restrict comment syntax to not contain --> or --!> (yuyokk著, ) https://github.com/whatwg/html/commit/4637996e5f1579659e0351a6fac5c930c3ea553e

[156] Web Applications 1.0 () https://web.archive.org/web/20050507071329/http://www.whatwg.org/specs/web-apps/current-work/#parsing

[157] Web Applications 1.0 () https://web.archive.org/web/20060202011253/http://whatwg.org/specs/web-apps/current-work/#parsing

[158] Make <menuitem> parse like an unknown element (zcorpan著, ) https://github.com/whatwg/html/commit/0ca0377a7ca6d87fb40e0b97e0ee074300b39a32

[159] Regression fix: ASCII lower alpha → ASCII upper alpha in the parser (annevk著, ) https://github.com/whatwg/html/commit/f1afebd3c04d12172ead806debf2bbbfff47f5e1

[160] Editorial: use noncharacter and control from Infra (annevk著, ) https://github.com/whatwg/html/commit/70925237a88d9802bfe7224fe9c78b146af615be

[161] Regression fix: deal with ASCII digits before ASCII hex digits (annevk著, ) https://github.com/whatwg/html/commit/f8e75a974ed9185e5b462bc5b2dfb32034bd1145

[162] Editorial: Introduce named character reference state (inikulin著, ) https://github.com/whatwg/html/commit/7d3201282d31c30cdba2583445d3727a94390286

[163] Editorial: Formalize markup declaration open state (inikulin著, ) https://github.com/whatwg/html/commit/2d5febb2ab617c915f1542744fef1b544bacb460

[164] Add unique ids to each parse error · Issue #1339 · whatwg/html () https://github.com/whatwg/html/issues/1339

[165] HTML Parse Error Standartization Working Group () https://github.com/HTMLParseErrorWG

[166] meta/WORKFLOW.md at master · HTMLParseErrorWG/meta () https://github.com/HTMLParseErrorWG/meta/blob/master/WORKFLOW.md

[167] Remove parse error on NULLs from input stream preprocessing stage (inikulin著, ) https://github.com/whatwg/html/commit/8fa65b73575ed692ec7f75665bde32134acc4dd6

[168] Assign IDs to and explain all tokenization parse errors (inikulin著, ) https://github.com/whatwg/html/commit/32dbd7d5b938ffda725e74dba8a50ed0c3b83b6d

[169] Allow not executing scripts inserted by document.write() (domenic著, ) https://github.com/whatwg/html/commit/15b258dc74ffe1ba321b81a1c876f129681a97c2

[171] Clarify that 0x0D CR is not allowed in entities (Alcaro著, ) https://github.com/whatwg/html/commit/efcf0af907c13343d898bf47b5ab004ed59724dd

[172] Handle ambiguous ampersands of arbitrary length (inikulin著, ) https://github.com/whatwg/html/commit/ee198945e388bd3298b73fb842fa0175d5b6a0f9

[173] [Parser] Handle ambiguous ampersands of arbitrary length (closes #1257) by inikulin · Pull Request #2731 · whatwg/html () https://github.com/whatwg/html/pull/2731

[174] Make U+0000 a parse error in bogus comment and bogus DOCTYPE states (zcorpan著, ) https://github.com/whatwg/html/commit/5a6fef58056832140fecf1580ca815f385730cec

[175] Parse errors on NULLs in bogus comment. · Issue #2684 · whatwg/html () https://github.com/whatwg/html/issues/2684

[176] Make U+0000 a parse error in bogus comment and bogus DOCTYPE states by zcorpan · Pull Request #2939 · whatwg/html () https://github.com/whatwg/html/pull/2939

[177] Track HTML parser form-associated elements with a flag (annevk著, ) https://github.com/whatwg/html/commit/384c30c56d6dfd26dfbd3a5024ae10e7f7134483

[178] Remove <applet> (except for parsing rules) · Issue #454 · whatwg/html () https://github.com/whatwg/html/issues/454

[179] Regression fix: Lost ampersands in Character Reference State's Anythi… (JonathanO著, ) https://github.com/whatwg/html/commit/8d2875784cd4684fd85f4421a1d173902d0e1760

[180] Editorial: Clarify what happens to U+0000 chars (sideshowbarker著, ) https://github.com/whatwg/html/commit/05d0ae71e82871e2fd1785829d180218da83abe7

[181] Editorial: Clarify what happens to U+0000 chars by sideshowbarker · Pull Request #2968 · whatwg/html () https://github.com/whatwg/html/pull/2968

[182] Improve <style> and <script> processing and conformance (domenic著, ) https://github.com/whatwg/html/commit/9c612ac8641b5174849a2d3cb924fe662a8d3a09

[183] Improve <style> and <script> processing and conformance by domenic · Pull Request #3024 · whatwg/html () https://github.com/whatwg/html/pull/3024

[184] Require UTF-8 (sideshowbarker著, ) https://github.com/whatwg/html/commit/fae77e3c558b9f083dfb9086752863a4789268f5

[185] Elements with duplicated attributes are not nonceable. (mikewest著, ) https://github.com/w3c/webappsec-csp/commit/649393514b9aaf9277bfd21ee1834f4befd029be

[186] Editorial: further cleanup "abort these steps" (shreyateeza著, ) https://github.com/whatwg/html/commit/99e2cdfc484c2ff14cbf5c38b859f4d6da17e64c

[187] Allow UAs to conditionally block on stylesheet loading (domfarolino著, ) https://github.com/whatwg/html/commit/42dd707cbfc0f5d8f88b04ef270f4fcb121a10ff

[188] Hide `nonce` content attribute values. (#2369) by mikewest · Pull Request #2373 · whatwg/html () https://github.com/whatwg/html/pull/2373

[191] "Hexademical character reference start state" · Issue #4006 · whatwg/html () https://github.com/whatwg/html/issues/4006

[192] Editorial: sentence-case “Escapable raw text elements” (eeeps著, ) https://github.com/whatwg/html/commit/b921d020af9523ac4e4972097ef20530185ca939

[193] "escapable raw text elements" · Issue #3895 · whatwg/html () https://github.com/whatwg/html/issues/3895

[194] Editorial: sentence-case “Escapable raw text elements” by eeeps · Pull Request #3896 · whatwg/html () https://github.com/whatwg/html/pull/3896

[195] Restrict application caches to secure contexts (annevk著, ) https://github.com/whatwg/html/commit/81344cc9f567bfafaed57805fd9cdf9f4a4237bf

[196] Treat CR, LF, CRLF the same for alert/confirm/prompt (domenic著, ) https://github.com/whatwg/html/commit/76638126838951c21aee4a1220cd0a4e57f3081d

[197] [CITE@lang=[EUも廃止の方向へ。日本のサマータイム導入って結局どうなった? | ジョイキャリア]] () https://career.joi.media/workstyle/2019/05/24/8879/?source=category

<!doctype html><html lang="lang="ja"

prefix="og: http://ogp.me/ns#" "><head>

[198] Idiosyncrasies of the HTML parser - The HTML Parser Book () https://htmlparser.info/

[199] zcorpan/html-parser-book: Idiosyncracies of the HTML parser () https://github.com/zcorpan/html-parser-book/

[200] HTML を取り扱う | ちいさな Web ブラウザを作ってみよう, , https://browserbook.shift-js.info/chapters/parsing-html

他の多くのプログラミング言語と異なり、HTML の取り扱いがやっかいな理由の一つに、HTML Standard は HTML の字句規則や構文規則が正規表現や BNF のような形で記述されていないという事実が挙げられます。 本来、正規表現や BNF のような形で HTML の字句規則や構文規則が定義されているのであれば、HTML の取り扱いには、一般的なコンパイラ作成のときの考え方をそのまま適用できるはずなのにです。 とりわけ世の中には flex や bison といった字句解析器・構文解析器を生成するためのツールも存在しますから、この場合、実装難易度は大きく下がるはずです。

いま、HTML の構文が BNF のような形で記述されていない背景には、多少マークアップが雑でも Web ページの利用に支障が出ないように、HTML が非常にゆるい文法を採用していることが挙げられます。

[201] >>200 この説明は誤りHTMLBNF を使わないのは、 BNF では HTML構文解析器を正確に記述できないから。 「生成規則を flex や bison に食わせれば構文解析器は簡単に作れる」 というまさにその考え方 (によってもたらされる相互運用性の低下) への反省が今の HTML Standard を形作っている。

[202] HTML StandardBNF を使っていないのは、 「ゆるい文法」 が BNF で記述できないからではない。 実際、 HTML Standard の (構文解析器ではなく) HTML構文の章は、 英語で書かれているが、 BNF にほぼ逐語訳できる。 文法を BNF で書けるかどうかと構文解析器の挙動は別の問題で、 それぞれちゃんと記述したのが HTML5 の成果。

[216] HTML要素概説
注釈