Xem mẫu

HTML5 (including next generation additions still in development) Draft Standard — 7 April 2010 You can take part in this work. Join the working group`s discussion list. Web designers! We have a FAQ, a forum, and a help mailing list for you! Multiple-page version: http://whatwg.org/html5 One-page version: http://www.whatwg.org/specs/web-apps/current-work/ PDF print versions: A4: http://www.whatwg.org/specs/web-apps/current-work/html5-a4.pdf Letter: http://www.whatwg.org/specs/web-apps/current-work/html5-letter.pdf Version history: Twitter messages (non-editorial changes only): http://twitter.com/WHATWG Commit-Watchers mailing list: http://lists.whatwg.org/listinfo.cgi/commit-watchers-whatwg.org Interactive Web interface: http://html5.org/tools/web-apps-tracker Subversion interface: http://svn.whatwg.org/ Issues: To send feedback: whatwg@whatwg.org To view and vote on feedback: http://www.whatwg.org/issues/ Editor: Ian Hickson, Google, ian@hixie.ch © Copyright 2004-2010 Apple Computer, Inc., Mozilla Foundation, and Opera Software ASA. You are granted a license to use, reproduce and create derivative works of this document. Abstract This specification evolves HTML and its related APIs to ease the authoring of Web-based applications. The most recent additions include a devicep401 element to enable video conferencing, as well as all the features added as part of the earlier HTML5 effort. 1 Status of this document This is a work in progress! This document is changing on a daily if not hourly basis in response to comments and as a general part of its development process. Comments are very welcome, please send them to whatwg@whatwg.org. Thank you. Outstanding feedback is tracked; all e-mails sent to the list above receive a reply. The level of outstanding feedback is charted to allow progress to be evaluated. Implementors should be aware that this specification is not stable. Implementors who are not taking part in the discussions are likely to find the specification changing out from under them in incompatible ways. Vendors interested in implementing this specification before it eventually reaches the call for implementations should join the WHATWG mailing list and take part in the discussions. This specification is intended to replace (be the new version of) what was previously the HTML5, HTML4, XHTML1, and DOM2 HTML specifications. 2 Table of contents 1 Introduction..................................................................................................................................................16 1.1 Is this HTML5?............................................................................................................................16 1.2 Background................................................................................................................................16 1.3 Audience....................................................................................................................................16 1.4 Scope.........................................................................................................................................17 1.5 History.......................................................................................................................................17 1.6 Design notes..............................................................................................................................18 1.6.1 Serializability of script execution ............................................................................18 1.6.2 Compliance with other specifications......................................................................18 1.7 HTML vs XHTML.........................................................................................................................19 1.8 Structure of this specification....................................................................................................19 1.8.1 How to read this specification.................................................................................20 1.8.2 Typographic conventions ........................................................................................20 1.9 A quick introduction to HTML.....................................................................................................20 1.10 Conformance requirements for authors...................................................................................22 1.10.1 Presentational markup..........................................................................................23 1.10.2 Syntax errors ........................................................................................................23 1.10.3 Restrictions on content models and on attribute values.......................................25 1.11 Recommended reading............................................................................................................27 2 Common infrastructure ................................................................................................................................28 2.1 Terminology ...............................................................................................................................28 2.1.1 Resources ...............................................................................................................28 2.1.2 XML.........................................................................................................................28 2.1.3 DOM trees...............................................................................................................29 2.1.4 Scripting..................................................................................................................29 2.1.5 Plugins ....................................................................................................................29 2.1.6 Character encodings...............................................................................................30 2.2 Conformance requirements .......................................................................................................30 2.2.1 Dependencies.........................................................................................................33 2.2.2 Extensibility ............................................................................................................34 2.3 Case-sensitivity and string comparison.....................................................................................35 2.4 Common microsyntaxes ............................................................................................................36 2.4.1 Common parser idioms...........................................................................................36 2.4.2 Boolean attributes ..................................................................................................37 2.4.3 Keywords and enumerated attributes.....................................................................37 2.4.4 Numbers .................................................................................................................37 2.4.4.1 Non-negative integers..........................................................................37 2.4.4.2 Signed integers....................................................................................38 2.4.4.3 Real numbers.......................................................................................38 2.4.4.4 Percentages and lengths......................................................................40 2.4.4.5 Lists of integers....................................................................................41 2.4.4.6 Lists of dimensions...............................................................................42 2.4.5 Dates and times......................................................................................................43 2.4.5.1 Months .................................................................................................43 2.4.5.2 Dates....................................................................................................44 2.4.5.3 Times ...................................................................................................45 2.4.5.4 Local dates and times ..........................................................................46 2.4.5.5 Global dates and times ........................................................................46 2.4.5.6 Weeks...................................................................................................48 2.4.5.7 Vaguer moments in time......................................................................49 2.4.6 Colors......................................................................................................................50 2.4.7 Space-separated tokens..........................................................................................52 2.4.8 Comma-separated tokens.......................................................................................53 2.4.9 References..............................................................................................................54 2.4.10 Media queries .......................................................................................................54 2.5 URLs ..........................................................................................................................................54 2.5.1 Terminology ............................................................................................................54 2.5.2 Dynamic changes to base URLs..............................................................................56 2.5.3 Interfaces for URL manipulation..............................................................................56 2.6 Fetching resources.....................................................................................................................58 2.6.1 Protocol concepts....................................................................................................60 3 2.6.2 Encrypted HTTP and related security concerns.......................................................60 2.6.3 Determining the type of a resource ........................................................................61 2.7 Common DOM interfaces...........................................................................................................61 2.7.1 Reflecting content attributes in IDL attributes........................................................61 2.7.2 Collections ..............................................................................................................63 2.7.2.1 HTMLCollection.....................................................................................63 2.7.2.2 HTMLAllCollection.................................................................................64 2.7.2.3 HTMLFormControlsCollection................................................................65 2.7.2.4 HTMLOptionsCollection ........................................................................66 2.7.2.5 HTMLPropertiesCollection.....................................................................68 2.7.3 DOMTokenList..........................................................................................................69 2.7.4 DOMSettableTokenList ............................................................................................71 2.7.5 Safe passing of structured data..............................................................................71 2.7.6 DOMStringMap........................................................................................................72 2.7.7 DOM feature strings................................................................................................73 2.7.8 Exceptions ..............................................................................................................74 2.7.9 Garbage collection..................................................................................................74 2.8 Namespaces..............................................................................................................................74 3 Semantics, structure, and APIs of HTML documents.....................................................................................75 3.1 Documents ................................................................................................................................75 3.1.1 Documents in the DOM...........................................................................................75 3.1.2 Security...................................................................................................................77 3.1.3 Resource metadata management...........................................................................77 3.1.4 DOM tree accessors................................................................................................80 3.1.5 Creating documents................................................................................................83 3.2 Elements....................................................................................................................................84 3.2.1 Semantics...............................................................................................................84 3.2.2 Elements in the DOM ..............................................................................................85 3.2.3 Global attributes.....................................................................................................87 3.2.3.1 The id attribute ...................................................................................89 3.2.3.2 The title attribute..............................................................................89 3.2.3.3 The lang and xml:lang attributes.......................................................89 3.2.3.4 The xml:base attribute (XML only) ......................................................90 3.2.3.5 The dir attribute..................................................................................90 3.2.3.6 The class attribute..............................................................................91 3.2.3.7 The style attribute..............................................................................91 3.2.3.8 Embedding custom non-visible data ....................................................92 3.2.4 Element definitions.................................................................................................94 3.2.5 Content models.......................................................................................................94 3.2.5.1 Kinds of content...................................................................................95 3.2.5.1.1 Metadata content..............................................................95 3.2.5.1.2 Flow content......................................................................96 3.2.5.1.3 Sectioning content.............................................................96 3.2.5.1.4 Heading content................................................................96 3.2.5.1.5 Phrasing content ...............................................................96 3.2.5.1.6 Embedded content............................................................97 3.2.5.1.7 Interactive content............................................................97 3.2.5.2 Transparent content models.................................................................98 3.2.5.3 Paragraphs...........................................................................................98 3.2.6 Annotations for assistive technology products (ARIA)...........................................100 3.3 APIs in HTML documents..........................................................................................................103 3.4 Interactions with XPath and XSLT.............................................................................................104 3.5 Dynamic markup insertion.......................................................................................................105 3.5.1 Opening the input stream.....................................................................................105 3.5.2 Closing the input stream.......................................................................................106 3.5.3 document.write() ...............................................................................................107 3.5.4 document.writeln() ...........................................................................................108 3.5.5 innerHTML.............................................................................................................108 3.5.6 outerHTML.............................................................................................................109 3.5.7 insertAdjacentHTML()........................................................................................109 4 The elements of HTML................................................................................................................................112 4.1 The root element.....................................................................................................................112 4.1.1 The html element.................................................................................................112 4 4.2 Document metadata................................................................................................................112 4.2.1 The head element.................................................................................................112 4.2.2 The title element ...............................................................................................113 4.2.3 The base element.................................................................................................114 4.2.4 The link element.................................................................................................115 4.2.5 The meta element.................................................................................................119 4.2.5.1 Standard metadata names.................................................................120 4.2.5.2 Other metadata names......................................................................121 4.2.5.3 Pragma directives ..............................................................................122 4.2.5.4 Other pragma directives ....................................................................125 4.2.5.5 Specifying the document`s character encoding .................................125 4.2.6 The style element ...............................................................................................126 4.2.7 Styling...................................................................................................................128 4.3 Scripting ..................................................................................................................................129 4.3.1 The script element .............................................................................................129 4.3.1.1 Scripting languages............................................................................134 4.3.1.2 Restrictions for contents of script elements ....................................135 4.3.1.3 Inline documentation for external scripts...........................................136 4.3.2 The noscript element..........................................................................................136 4.4 Sections...................................................................................................................................138 4.4.1 The body element.................................................................................................138 4.4.2 The section element ...........................................................................................140 4.4.3 The nav element...................................................................................................142 4.4.4 The article element ...........................................................................................144 4.4.5 The aside element ...............................................................................................145 4.4.6 The h1, h2, h3, h4, h5, and h6 elements ...............................................................147 4.4.7 The hgroup element .............................................................................................148 4.4.8 The header element .............................................................................................148 4.4.9 The footer element .............................................................................................150 4.4.10 The address element .........................................................................................151 4.4.11 Headings and sections........................................................................................152 4.4.11.1 Creating an outline...........................................................................153 4.5 Grouping content.....................................................................................................................157 4.5.1 The p element.......................................................................................................157 4.5.2 The hr element.....................................................................................................158 4.5.3 The pre element...................................................................................................158 4.5.4 The blockquote element......................................................................................159 4.5.5 The ol element.....................................................................................................161 4.5.6 The ul element.....................................................................................................162 4.5.7 The li element.....................................................................................................163 4.5.8 The dl element.....................................................................................................164 4.5.9 The dt element.....................................................................................................166 4.5.10 The dd element...................................................................................................166 4.5.11 The figure element ...........................................................................................167 4.5.12 The figcaption element....................................................................................168 4.5.13 The div element.................................................................................................168 4.6 Text-level semantics ................................................................................................................169 4.6.1 The a element.......................................................................................................169 4.6.2 The em element.....................................................................................................171 4.6.3 The strong element .............................................................................................172 4.6.4 The small element ...............................................................................................173 4.6.5 The cite element.................................................................................................174 4.6.6 The q element.......................................................................................................175 4.6.7 The dfn element...................................................................................................176 4.6.8 The abbr element.................................................................................................177 4.6.9 The time element.................................................................................................178 4.6.10 The code element...............................................................................................181 4.6.11 The var element.................................................................................................182 4.6.12 The samp element...............................................................................................182 4.6.13 The kbd element.................................................................................................183 4.6.14 The sub and sup elements..................................................................................184 4.6.15 The i element.....................................................................................................184 4.6.16 The b element.....................................................................................................185 4.6.17 The mark element...............................................................................................186 4.6.18 The ruby element...............................................................................................188 5 ... - tailieumienphi.vn
nguon tai.lieu . vn