HTML 5

Draft Recommendation — 6 October 2008

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/
HTML diff with the last version in Subversion: http://whatwg.org/specs/web-apps/current-work/index-diff
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

Abstract

This specification evolves HTML and its related APIs to ease the authoring of Web-based applications. Additions include context menus, a direct-mode graphics canvas, a full duplex client-server communication channel, more semantics, audio and video, various features for offline Web applications, sandboxed iframes, and scoped styling. Heavy emphasis is placed on keeping the language backwards compatible with existing legacy user agents and on keeping user agents backwards compatible with existing legacy documents.

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.

The current focus is in responding to the outstanding feedback . (There is a chart showing current progress.)

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 also being produced by the W3C HTML WG . The two specifications are identical from the table of contents onwards.

This specification is intended to replace (be the new version of) what was previously the HTML4, XHTML 1.x, and DOM2 HTML specifications.

Stability

Different parts of this specification are at different levels of maturity.

Some of the more major known issues are marked like this. There are many other issues that have been raised as well; the issues given in this document are not the only known issues! Also, firing of events needs to be unified (right now some bubble, some don't, they all use different text to fire events, etc).

Table of contents

  1. 1 Introduction
    1. 1.1 Background
    2. 1.2 Scope
    3. 1.3 History
    4. 1.4 Relationships to other specifications
      1. 1.4.1 Relationship to HTML 4.01 and DOM2 HTML
      2. 1.4.2 Relationship to XHTML 1.x
      3. 1.4.3 Relationship to XHTML2 and XForms
      4. 1.4.4 Relationship to XUL, Flash, Silverlight, and other proprietary UI languages
    5. 1.5 HTML vs XHTML
    6. 1.6 Structure of this specification
      1. 1.6.1 How to read this specification
      2. 1.6.2 Typographic conventions
  2. 2 Common infrastructure
    1. 2.1 Terminology
      1. 2.1.1 XML
      2. 2.1.2 DOM trees
      3. 2.1.3 Scripting
      4. 2.1.4 Plugins
      5. 2.1.5 Character encodings
    2. 2.2 Conformance requirements
      1. 2.2.1 Dependencies
      2. 2.2.2 Features defined in other specifications
      3. 2.2.3 Common conformance requirements for APIs exposed to JavaScript
    3. 2.3 Case-sensitivity
    4. 2.4 Common microsyntaxes
      1. 2.4.1 Common parser idioms
      2. 2.4.2 Boolean attributes
      3. 2.4.3 Numbers
        1. 2.4.3.1 Unsigned integers
        2. 2.4.3.2 Signed integers
        3. 2.4.3.3 Real numbers
        4. 2.4.3.4 Ratios
        5. 2.4.3.5 Percentages and dimensions
        6. 2.4.3.6 Lists of integers
      4. 2.4.4 Dates and times
        1. 2.4.4.1 Specific moments in time
        2. 2.4.4.2 Vaguer moments in time
        3. 2.4.4.3 UTC dates and times
        4. 2.4.4.4 Local dates and times
        5. 2.4.4.5 Dates
        6. 2.4.4.6 Months
        7. 2.4.4.7 Weeks
        8. 2.4.4.8 Times
        9. 2.4.4.9 Time offsets
      5. 2.4.5 Space-separated tokens
      6. 2.4.6 Comma-separated tokens
      7. 2.4.7 Keywords and enumerated attributes
      8. 2.4.8 References
    5. 2.5 URLs
      1. 2.5.1 Terminology
      2. 2.5.2 Parsing URLs
      3. 2.5.3 Resolving URLs
      4. 2.5.4 Dynamic changes to base URLs
      5. 2.5.5 Interfaces for URL manipulation
    6. 2.6 Fetching resources
    7. 2.7 Determining the type of a resource
      1. 2.7.1 Content-Type metadata
      2. 2.7.2 Content-Type sniffing: Web pages
      3. 2.7.3 Content-Type sniffing: text or binary
      4. 2.7.4 Content-Type sniffing: unknown type
      5. 2.7.5 Content-Type sniffing: image
      6. 2.7.6 Content-Type sniffing: feed or HTML
    8. 2.8 Common DOM interfaces
      1. 2.8.1 Reflecting content attributes in DOM attributes
      2. 2.8.2 Collections
        1. 2.8.2.1 HTMLCollection
        2. 2.8.2.2 HTMLFormControlsCollection
        3. 2.8.2.3 HTMLOptionsCollection
      3. 2.8.3 DOMTokenList
      4. 2.8.4 DOMStringMap
      5. 2.8.5 DOM feature strings
  3. 3 Semantics and structure of HTML documents
    1. 3.1 Introduction
    2. 3.2 Documents
      1. 3.2.1 Documents in the DOM
      2. 3.2.2 Security
      3. 3.2.3 Resource metadata management
      4. 3.2.4 DOM tree accessors
    3. 3.3 Elements
      1. 3.3.1 Semantics
      2. 3.3.2 Elements in the DOM
      3. 3.3.3 Global attributes
        1. 3.3.3.1 The id attribute
        2. 3.3.3.2 The title attribute
        3. 3.3.3.3 The lang and xml:lang attributes
        4. 3.3.3.4 The xml:base attribute (XML only)
        5. 3.3.3.5 The dir attribute
        6. 3.3.3.6 The class attribute
        7. 3.3.3.7 The style attribute
        8. 3.3.3.8 Embedding custom non-visible data
    4. 3.4 Content models
      1. 3.4.1 Kinds of content
        1. 3.4.1.1 Metadata content
        2. 3.4.1.2 Flow content
        3. 3.4.1.3 Sectioning content
        4. 3.4.1.4 Heading content
        5. 3.4.1.5 Phrasing content
        6. 3.4.1.6 Embedded content
        7. 3.4.1.7 Interactive content
      2. 3.4.2 Transparent content models
    5. 3.5 Paragraphs
    6. 3.6 APIs in HTML documents
    7. 3.7 Dynamic markup insertion
      1. 3.7.1 Controlling the input stream
      2. 3.7.2 Dynamic markup insertion in HTML
      3. 3.7.3 Dynamic markup insertion in XML
  4. 4 The elements of HTML
    1. 4.1 The root element
      1. 4.1.1 The html element
    2. 4.2 Document metadata
      1. 4.2.1 The head element
      2. 4.2.2 The title element
      3. 4.2.3 The base element
      4. 4.2.4 The link element
      5. 4.2.5 The meta element
        1. 4.2.5.1 Standard metadata names
        2. 4.2.5.2 Other metadata names
        3. 4.2.5.3 Pragma directives
        4. 4.2.5.4 Specifying the document's character encoding
      6. 4.2.6 The style element
      7. 4.2.7 Styling
    3. 4.3 Scripting
      1. 4.3.1 The script element
        1. 4.3.1.1 Scripting languages
      2. 4.3.2 The noscript element
      3. 4.3.3 The eventsource element
    4. 4.4 Sections
      1. 4.4.1 The body element
      2. 4.4.2 The section element
      3. 4.4.3 The nav element
      4. 4.4.4 The article element
      5. 4.4.5 The aside element
      6. 4.4.6 The h1 , h2 , h3 , h4 , h5 , and h6 elements
      7. 4.4.7 The header element
      8. 4.4.8 The footer element
      9. 4.4.9 The address element
      10. 4.4.10 Headings and sections
        1. 4.4.10.1 Creating an outline
        2. 4.4.10.2 Distinguishing site-wide headings from page headings
    5. 4.5 Grouping content
      1. 4.5.1 The p element
      2. 4.5.2 The hr element
      3. 4.5.3 The br element
      4. 4.5.4 The pre element
      5. 4.5.5 The dialog element
      6. 4.5.6 The blockquote element
      7. 4.5.7 The ol element
      8. 4.5.8 The ul element
      9. 4.5.9 The li element
      10. 4.5.10 The dl element
      11. 4.5.11 The dt element
      12. 4.5.12 The dd element
    6. 4.6 Text-level semantics
      1. 4.6.1 The a element
      2. 4.6.2 The q element
      3. 4.6.3 The cite element
      4. 4.6.4 The em element
      5. 4.6.5 The strong element
      6. 4.6.6 The small element
      7. 4.6.7 The mark element
      8. 4.6.8 The dfn element
      9. 4.6.9 The abbr element
      10. 4.6.10 The time element
      11. 4.6.11 The progress element
      12. 4.6.12 The meter element
      13. 4.6.13 The code element
      14. 4.6.14 The var element
      15. 4.6.15 The samp element
      16. 4.6.16 The kbd element
      17. 4.6.17 The sub and sup elements
      18. 4.6.18 The span element
      19. 4.6.19 The i element
      20. 4.6.20 The b element
      21. 4.6.21 The bdo element
      22. 4.6.22 The ruby element
      23. 4.6.23 The rt element
      24. 4.6.24 The rp element
      25. 4.6.25 Usage summary
      26. 4.6.26 Footnotes
    7. 4.7 Edits
      1. 4.7.1 The ins element
      2. 4.7.2 The del element
      3. 4.7.3 Attributes common to ins and del elements
      4. 4.7.4 Edits and paragraphs
      5. 4.7.5 Edits and lists
    8. 4.8 Embedded content
      1. 4.8.1 The figure element
      2. 4.8.2 The img element
        1. 4.8.2.1 Requirements for providing text to act as an alternative for images
          1. 4.8.2.1.1 A link or button containing nothing but the image
          2. 4.8.2.1.2 A phrase or paragraph with an alternative graphical representation: charts, diagrams, graphs, maps, illustrations
          3. 4.8.2.1.3 A short phrase or label with an alternative graphical representation: icons, logos
          4. 4.8.2.1.4 Text that has been rendered to a graphic for typographical effect
          5. 4.8.2.1.5 A graphical representation of some of the surrounding text
          6. 4.8.2.1.6 A purely decorative image that doesn't add any information but is still specific to the surrounding content
          7. 4.8.2.1.7 A group of images that form a single larger picture with no links
          8. 4.8.2.1.8 A group of images that form a single larger picture with links
          9. 4.8.2.1.9 A key part of the content
          10. 4.8.2.1.10 An image not intended for the user
          11. 4.8.2.1.11 An image in an e-mail or document intended for a specific person who is known to be able to view images
          12. 4.8.2.1.12 General guidelines
      3. 4.8.3 The iframe element
      4. 4.8.4 The embed element
      5. 4.8.5 The object element
      6. 4.8.6 The param element
      7. 4.8.7 The video element
        1. 4.8.7.1 Video and audio codecs for video elements
      8. 4.8.8 The audio element
        1. 4.8.8.1 Audio codecs for audio elements
      9. 4.8.9 The source element
      10. 4.8.10 Media elements
        1. 4.8.10.1 Error codes
        2. 4.8.10.2 Location of the media resource
        3. 4.8.10.3 Network states
        4. 4.8.10.4 Loading the media resource
        5. 4.8.10.5 Offsets into the media resource
        6. 4.8.10.6 The ready states
        7. 4.8.10.7 Playing the media resource
        8. 4.8.10.8 Seeking
        9. 4.8.10.9 Cue ranges
        10. 4.8.10.10 User interface
        11. 4.8.10.11 Time ranges
        12. 4.8.10.12 Byte ranges
        13. 4.8.10.13 Event summary
        14. 4.8.10.14 Security and privacy considerations
      11. 4.8.11 The canvas element
        1. 4.8.11.1 The 2D context
          1. 4.8.11.1.1 The canvas state
          2. 4.8.11.1.2 Transformations
          3. 4.8.11.1.3 Compositing
          4. 4.8.11.1.4 Colors and styles
          5. 4.8.11.1.5 Line styles
          6. 4.8.11.1.6 Shadows
          7. 4.8.11.1.7 Simple shapes (rectangles)
          8. 4.8.11.1.8 Complex shapes (paths)
          9. 4.8.11.1.9 Text
          10. 4.8.11.1.10 Images
          11. 4.8.11.1.11 Pixel manipulation
          12. 4.8.11.1.12 Drawing model
        2. 4.8.11.2 Color spaces and color correction
        3. 4.8.11.3 Security with canvas elements
      12. 4.8.12 The map element
      13. 4.8.13 The area element
      14. 4.8.14 Image maps
        1. 4.8.14.1 Authoring
        2. 4.8.14.2 Processing model
      15. 4.8.15 MathML
      16. 4.8.16 SVG
      17. 4.8.17 Dimension attributes
    9. 4.9 Tabular data
      1. 4.9.1 Introduction
      2. 4.9.2 The table element
      3. 4.9.3 The caption element
      4. 4.9.4 The colgroup element
      5. 4.9.5 The col element
      6. 4.9.6 The tbody element
      7. 4.9.7 The thead element
      8. 4.9.8 The tfoot element
      9. 4.9.9 The tr element
      10. 4.9.10 The td element
      11. 4.9.11 The th element
      12. 4.9.12 Attributes common to td and th elements
      13. 4.9.13 Processing model
        1. 4.9.13.1 Forming a table
        2. 4.9.13.2 Forming relationships between data cells and header cells
    10. 4.10 Forms
      1. 4.10.1 The form element
      2. 4.10.2 The fieldset element
      3. 4.10.3 The label element
      4. 4.10.4 The input element
        1. 4.10.4.1 States of the type attribute
          1. 4.10.4.1.1 Hidden state
          2. 4.10.4.1.2 Text state
          3. 4.10.4.1.3 E-mail state
          4. 4.10.4.1.4 URL state
          5. 4.10.4.1.5 Password state
          6. 4.10.4.1.6 Date and Time state
          7. 4.10.4.1.7 Date state
          8. 4.10.4.1.8 Month state
          9. 4.10.4.1.9 Week state
          10. 4.10.4.1.10 Time state
          11. 4.10.4.1.11 Local Date and Time state
          12. 4.10.4.1.12 Number state
          13. 4.10.4.1.13 Range state
          14. 4.10.4.1.14 Checkbox state
          15. 4.10.4.1.15 Radio Button state
          16. 4.10.4.1.16 File Upload state
          17. 4.10.4.1.17 Submit Button state
          18. 4.10.4.1.18 Image Button state
          19. 4.10.4.1.19 Reset Button state
          20. 4.10.4.1.20 Button state
          21. 4.10.4.1.21 Common algorithms
        2. 4.10.4.2 Common input element attributes
          1. 4.10.4.2.1 The autocomplete attribute
          2. 4.10.4.2.2 The list attribute
          3. 4.10.4.2.3 The readonly attribute
          4. 4.10.4.2.4 The size attribute
          5. 4.10.4.2.5 The required attribute
          6. 4.10.4.2.6 The maxlength attribute
          7. 4.10.4.2.7 The pattern attribute
          8. 4.10.4.2.8 The min and max attributes
          9. 4.10.4.2.9 The step attribute
        3. 4.10.4.3 Common input element APIs
        4. 4.10.4.4 Common event behaviors
      5. 4.10.5 The button element
      6. 4.10.6 The select element
      7. 4.10.7 The datalist element
      8. 4.10.8 The optgroup element
      9. 4.10.9 The option element
      10. 4.10.10 The textarea element
      11. 4.10.11 The output element
      12. 4.10.12 Association of controls and forms
      13. 4.10.13 Attributes common to form controls
        1. 4.10.13.1 Naming form controls
        2. 4.10.13.2 Enabling and disabling form controls
        3. 4.10.13.3 A form control's value
        4. 4.10.13.4 Autofocusing a form control
      14. 4.10.14 Attributes for form submission
      15. 4.10.15 Constraints
        1. 4.10.15.1 Definitions
        2. 4.10.15.2 Constraint validation
        3. 4.10.15.3 The constraint validation API
      16. 4.10.16 Form submission
        1. 4.10.16.1 URL-encoded form data
        2. 4.10.16.2 Multipart form data
        3. 4.10.16.3 Plain text form data
      17. 4.10.17 Resetting a form
      18. 4.10.18 Event dispatch
    11. 4.11 Interactive elements
      1. 4.11.1 The details element
      2. 4.11.2 The datagrid element
        1. 4.11.2.1 The datagrid data model
        2. 4.11.2.2 How rows are identified
        3. 4.11.2.3 The data provider interface
        4. 4.11.2.4 The default data provider
          1. 4.11.2.4.1 Common default data provider method definitions for cells
        5. 4.11.2.5 Populating the datagrid element
        6. 4.11.2.6 Updating the datagrid
        7. 4.11.2.7 Requirements for interactive user agents
        8. 4.11.2.8 The selection
        9. 4.11.2.9 Columns and captions
      3. 4.11.3 The command element
      4. 4.11.4 The bb element
        1. 4.11.4.1 Browser button types
          1. 4.11.4.1.1 The make application state
      5. 4.11.5 The menu element
        1. 4.11.5.1 Introduction
        2. 4.11.5.2 Building menus and tool bars
        3. 4.11.5.3 Context menus
        4. 4.11.5.4 Toolbars
      6. 4.11.6 Commands
        1. 4.11.6.1 Using the a element to define a command
        2. 4.11.6.2 Using the button element to define a command
        3. 4.11.6.3 Using the input element to define a command
        4. 4.11.6.4 Using the option element to define a command
        5. 4.11.6.5 Using the command element to define a command
        6. 4.11.6.6 Using the bb element to define a command
    12. 4.12 Data Templates
      1. 4.12.1 Introduction
      2. 4.12.2 The datatemplate element
      3. 4.12.3 The rule element
      4. 4.12.4 The nest element
      5. 4.12.5 Global attributes for data templates
      6. 4.12.6 Processing model
        1. 4.12.6.1 The originalContent DOM attribute
        2. 4.12.6.2 The template attribute
        3. 4.12.6.3 The ref attribute
        4. 4.12.6.4 The NodeDataTemplate interface
        5. 4.12.6.5 Mutations
        6. 4.12.6.6 Updating the generated content
    13. 4.13 Miscellaneous elements
      1. 4.13.1 The legend element
      2. 4.13.2 The div element
  5. 5 Web browsers
    1. 5.1 Browsing contexts
      1. 5.1.1 Nested browsing contexts
        1. 5.1.1.1 Navigating nested browsing contexts in the DOM
      2. 5.1.2 Auxiliary browsing contexts
        1. 5.1.2.1 Navigating auxiliary browsing contexts in the DOM
      3. 5.1.3 Secondary browsing contexts
      4. 5.1.4 Security
      5. 5.1.5 Groupings of browsing contexts
      6. 5.1.6 Browsing context names
    2. 5.2 The default view
      1. 5.2.1 Security
      2. 5.2.2 APIs for creating and navigating browsing contexts by name
      3. 5.2.3 Accessing other browsing contexts
    3. 5.3 Origin
      1. 5.3.1 Relaxing the same-origin restriction
    4. 5.4 Scripting
      1. 5.4.1 Script execution contexts
      2. 5.4.2 Event loops
        1. 5.4.2.1 Generic task sources
      3. 5.4.3 Security exceptions
      4. 5.4.4 The javascript: protocol
      5. 5.4.5 Events
        1. 5.4.5.1 Event handler attributes
        2. 5.4.5.2 Event firing
        3. 5.4.5.3 Events and the Window object
        4. 5.4.5.4 Runtime script errors
    5. 5.5 User prompts
      1. 5.5.1 Simple dialogs
      2. 5.5.2 Printing
      3. 5.5.3 Dialogs implemented using separate documents
      4. 5.5.4 Notifications
    6. 5.6 System state and capabilities
      1. 5.6.1 Client identification
      2. 5.6.2 Custom protocol and content handlers
        1. 5.6.2.1 Security and privacy
        2. 5.6.2.2 Sample user interface
    7. 5.7 Offline Web applications
      1. 5.7.1 Introduction
      2. 5.7.2 Application caches
      3. 5.7.3 The cache manifest syntax
        1. 5.7.3.1 A sample manifest
        2. 5.7.3.2 Writing cache manifests
        3. 5.7.3.3 Parsing cache manifests
      4. 5.7.4 Updating an application cache
      5. 5.7.5 Processing model
        1. 5.7.5.1 Changes to the networking model
      6. 5.7.6 Application cache API
      7. 5.7.7 Browser state
    8. 5.8 Session history and navigation
      1. 5.8.1 The session history of browsing contexts
      2. 5.8.2 The History interface
      3. 5.8.3 Activating state object entries
      4. 5.8.4 The Location interface
        1. 5.8.4.1 Security
      5. 5.8.5 Implementation notes for session history
    9. 5.9 Browsing the Web
      1. 5.9.1 Navigating across documents
      2. 5.9.2 Page load processing model for HTML files
      3. 5.9.3 Page load processing model for XML files
      4. 5.9.4 Page load processing model for text files
      5. 5.9.5 Page load processing model for images
      6. 5.9.6 Page load processing model for content that uses plugins
      7. 5.9.7 Page load processing model for inline content that doesn't have a DOM
      8. 5.9.8 Navigating to a fragment identifier
      9. 5.9.9 History traversal
      10. 5.9.10 Closing a browsing context
    10. 5.10 Structured client-side storage
      1. 5.10.1 Storing name/value pairs
        1. 5.10.1.1 Introduction
        2. 5.10.1.2 The Storage interface
        3. 5.10.1.3 The sessionStorage attribute
        4. 5.10.1.4 The localStorage attribute
        5. 5.10.1.5 The storage event
          1. 5.10.1.5.1 Event definition
        6. 5.10.1.6 Threads
      2. 5.10.2 Database storage
        1. 5.10.2.1 Introduction
        2. 5.10.2.2 Databases
        3. 5.10.2.3 Executing SQL statements
        4. 5.10.2.4 Database query results
        5. 5.10.2.5 Errors
        6. 5.10.2.6 Processing model
      3. 5.10.3 Disk space
      4. 5.10.4 Privacy
        1. 5.10.4.1 User tracking
        2. 5.10.4.2 Cookie resurrection
      5. 5.10.5 Security
        1. 5.10.5.1 DNS spoofing attacks
        2. 5.10.5.2 Cross-directory attacks
        3. 5.10.5.3 Implementation risks
        4. 5.10.5.4 SQL and user agents
        5. 5.10.5.5 SQL injection
    11. 5.11 Links
      1. 5.11.1 Hyperlink elements
      2. 5.11.2 Following hyperlinks
        1. 5.11.2.1 Hyperlink auditing
      3. 5.11.3 Link types
        1. 5.11.3.1 Link type " alternate "
        2. 5.11.3.2 Link type " archives "
        3. 5.11.3.3 Link type " author "
        4. 5.11.3.4 Link type " bookmark "
        5. 5.11.3.5 Link type " external "
        6. 5.11.3.6 Link type " feed "
        7. 5.11.3.7 Link type " help "
        8. 5.11.3.8 Link type " icon "
        9. 5.11.3.9 Link type " license "
        10. 5.11.3.10 Link type " nofollow "
        11. 5.11.3.11 Link type " noreferrer "
        12. 5.11.3.12 Link type " pingback "
        13. 5.11.3.13 Link type " prefetch "
        14. 5.11.3.14 Link type " search "
        15. 5.11.3.15 Link type " stylesheet "
        16. 5.11.3.16 Link type " sidebar "
        17. 5.11.3.17 Link type " tag "
        18. 5.11.3.18 Hierarchical link types
          1. 5.11.3.18.1 Link type " index "
          2. 5.11.3.18.2 Link type " up "
        19. 5.11.3.19 Sequential link types
          1. 5.11.3.19.1 Link type " first "
          2. 5.11.3.19.2 Link type " last "
          3. 5.11.3.19.3 Link type " next "
          4. 5.11.3.19.4 Link type " prev "
        20. 5.11.3.20 Other link types
  6. 6 User Interaction
    1. 6.1 Introduction
    2. 6.2 The hidden attribute
    3. 6.3 Activation
    4. 6.4 Scrolling elements into view
    5. 6.5 Focus
      1. 6.5.1 Sequential focus navigation
      2. 6.5.2 Focus management
      3. 6.5.3 Document-level focus APIs
      4. 6.5.4 Element-level focus APIs
    6. 6.6 The text selection APIs
      1. 6.6.1 APIs for the browsing context selection
      2. 6.6.2 APIs for the text field selections
    7. 6.7 The contenteditable attribute
      1. 6.7.1 User editing actions
      2. 6.7.2 Making entire documents editable
    8. 6.8 Drag and drop
      1. 6.8.1 Introduction
      2. 6.8.2 The DragEvent and DataTransfer interfaces
      3. 6.8.3 Events fired during a drag-and-drop action
      4. 6.8.4 Drag-and-drop processing model
        1. 6.8.4.1 When the drag-and-drop operation starts or ends in another document
        2. 6.8.4.2 When the drag-and-drop operation starts or ends in another application
      5. 6.8.5 The draggable attribute
      6. 6.8.6 Copy and paste
        1. 6.8.6.1 Copy to clipboard
        2. 6.8.6.2 Cut to clipboard
        3. 6.8.6.3 Paste from clipboard
        4. 6.8.6.4 Paste from selection
      7. 6.8.7 Security risks in the drag-and-drop model
    9. 6.9 Undo history
      1. 6.9.1 The UndoManager interface
      2. 6.9.2 Undo: moving back in the undo transaction history
      3. 6.9.3 Redo: moving forward in the undo transaction history
      4. 6.9.4 The UndoManagerEvent interface and the undo and redo events
      5. 6.9.5 Implementation notes
    10. 6.10 Command APIs
  7. 7 Communication
    1. 7.1 Event definitions
    2. 7.2 Server-sent events
      1. 7.2.1 The RemoteEventTarget interface
      2. 7.2.2 Connecting to an event stream
      3. 7.2.3 Parsing an event stream
      4. 7.2.4 Interpreting an event stream
      5. 7.2.5 Notes
    3. 7.3 Web sockets
      1. 7.3.1 Introduction
      2. 7.3.2 The WebSocket interface
      3. 7.3.3 WebSocket Events
      4. 7.3.4 The Web Socket protocol
        1. 7.3.4.1 Client-side requirements
          1. 7.3.4.1.1 Handshake
          2. 7.3.4.1.2 Data framing
        2. 7.3.4.2 Server-side requirements
          1. 7.3.4.2.1 Minimal handshake
          2. 7.3.4.2.2 Handshake details
          3. 7.3.4.2.3 Data framing
        3. 7.3.4.3 Closing the connection
    4. 7.4 Cross-document messaging
      1. 7.4.1 Introduction
      2. 7.4.2 Security
        1. 7.4.2.1 Authors
        2. 7.4.2.2 User agents
      3. 7.4.3 Posting text
      4. 7.4.4 Posting message ports
      5. 7.4.5 Posting structured data
    5. 7.5 Channel messaging
      1. 7.5.1 Introduction
      2. 7.5.2 Message channels
      3. 7.5.3 Message ports
        1. 7.5.3.1 Ports and browsing contexts
        2. 7.5.3.2 Ports and garbage collection
  8. 8 The HTML syntax
    1. 8.1 Writing HTML documents
      1. 8.1.1 The DOCTYPE
      2. 8.1.2 Elements
        1. 8.1.2.1 Start tags
        2. 8.1.2.2 End tags
        3. 8.1.2.3 Attributes
        4. 8.1.2.4 Optional tags
        5. 8.1.2.5 Restrictions on content models
        6. 8.1.2.6 Restrictions on the contents of CDATA and RCDATA elements
      3. 8.1.3 Text
        1. 8.1.3.1 Newlines
      4. 8.1.4 Character references
      5. 8.1.5 CDATA sections
      6. 8.1.6 Comments
    2. 8.2 Parsing HTML documents
      1. 8.2.1 Overview of the parsing model
      2. 8.2.2 The input stream
        1. 8.2.2.1 Determining the character encoding
        2. 8.2.2.2 Character encoding requirements
        3. 8.2.2.3 Preprocessing the input stream
        4. 8.2.2.4 Changing the encoding while parsing
      3. 8.2.3 Parse state
        1. 8.2.3.1 The insertion mode
        2. 8.2.3.2 The stack of open elements
        3. 8.2.3.3 The list of active formatting elements
        4. 8.2.3.4 The element pointers
        5. 8.2.3.5 The scripting state
      4. 8.2.4 Tokenization
        1. 8.2.4.1 Data state
        2. 8.2.4.2 Character reference data state
        3. 8.2.4.3 Tag open state
        4. 8.2.4.4 Close tag open state
        5. 8.2.4.5 Tag name state
        6. 8.2.4.6 Before attribute name state
        7. 8.2.4.7 Attribute name state
        8. 8.2.4.8 After attribute name state
        9. 8.2.4.9 Before attribute value state
        10. 8.2.4.10 Attribute value (double-quoted) state
        11. 8.2.4.11 Attribute value (single-quoted) state
        12. 8.2.4.12 Attribute value (unquoted) state
        13. 8.2.4.13 Character reference in attribute value state
        14. 8.2.4.14 After attribute value (quoted) state
        15. 8.2.4.15 Self-closing start tag state
        16. 8.2.4.16 Bogus comment state
        17. 8.2.4.17 Markup declaration open state
        18. 8.2.4.18 Comment start state
        19. 8.2.4.19 Comment start dash state
        20. 8.2.4.20 Comment state
        21. 8.2.4.21 Comment end dash state
        22. 8.2.4.22 Comment end state
        23. 8.2.4.23 DOCTYPE state
        24. 8.2.4.24 Before DOCTYPE name state
        25. 8.2.4.25 DOCTYPE name state
        26. 8.2.4.26 After DOCTYPE name state
        27. 8.2.4.27 Before DOCTYPE public identifier state
        28. 8.2.4.28 DOCTYPE public identifier (double-quoted) state
        29. 8.2.4.29 DOCTYPE public identifier (single-quoted) state
        30. 8.2.4.30 After DOCTYPE public identifier state
        31. 8.2.4.31 Before DOCTYPE system identifier state
        32. 8.2.4.32 DOCTYPE system identifier (double-quoted) state
        33. 8.2.4.33 DOCTYPE system identifier (single-quoted) state
        34. 8.2.4.34 After DOCTYPE system identifier state
        35. 8.2.4.35 Bogus DOCTYPE state
        36. 8.2.4.36 CDATA section state
        37. 8.2.4.37 Tokenizing character references
      5. 8.2.5 Tree construction
        1. 8.2.5.1 Creating and inserting elements
        2. 8.2.5.2 Closing elements that have implied end tags
        3. 8.2.5.3 Foster parenting
        4. 8.2.5.4 The "initial" insertion mode
        5. 8.2.5.5 The "before html" insertion mode
        6. 8.2.5.6 The "before head" insertion mode
        7. 8.2.5.7 The "in head" insertion mode
        8. 8.2.5.8 The "in head noscript" insertion mode
        9. 8.2.5.9 The "after head" insertion mode
        10. 8.2.5.10 The "in body" insertion mode
        11. 8.2.5.11 The "in CDATA/RCDATA" insertion mode
        12. 8.2.5.12 The "in table" insertion mode
        13. 8.2.5.13 The "in caption" insertion mode
        14. 8.2.5.14 The "in column group" insertion mode
        15. 8.2.5.15 The "in table body" insertion mode
        16. 8.2.5.16 The "in row" insertion mode
        17. 8.2.5.17 The "in cell" insertion mode
        18. 8.2.5.18 The "in select" insertion mode
        19. 8.2.5.19 The "in select in table" insertion mode
        20. 8.2.5.20 The "in foreign content" insertion mode
        21. 8.2.5.21 The "after body" insertion mode
        22. 8.2.5.22 The "in frameset" insertion mode
        23. 8.2.5.23 The "after frameset" insertion mode
        24. 8.2.5.24 The "after after body" insertion mode
        25. 8.2.5.25 The "after after frameset" insertion mode
      6. 8.2.6 The end
      7. 8.2.7 Coercing an HTML DOM into an infoset
    3. 8.3 Namespaces
    4. 8.4 Serializing HTML fragments
    5. 8.5 Parsing HTML fragments
    6. 8.6 Named character references
  9. 9 Rendering and user-agent behavior
    1. 9.1 Rendering and the DOM
    2. 9.2 Rendering and menus/toolbars
      1. 9.2.1 The 'icon' property
    3. 9.3 Obsolete elements, attributes, and APIs
      1. 9.3.1 The body element
      2. 9.3.2 The applet element
  10. 10 Things that you can't do with this specification because they are better handled using other technologies that are further described herein
    1. 10.1 Localization
    2. 10.2 Declarative 2D vector graphics and animation
    3. 10.3 Declarative 3D scenes
    4. 10.4 Timers
  11. Index
  12. References
  13. Acknowledgements

1 Introduction

1.1 Background

This section is non-normative.

The World Wide Web's markup language has always been HTML. HTML was primarily designed as a language for semantically describing scientific documents, although its general design and adaptations over the years has enabled it to be used to describe a number of other types of documents.

The main area that has not been adequately addressed by HTML is a vague subject referred to as Web Applications. This specification attempts to rectify this, while at the same time updating the HTML specifications to address issues raised in the past few years.

1.2 Scope

This section is non-normative.

This specification is limited to providing a semantic-level markup language and associated semantic-level scripting APIs for authoring accessible pages on the Web ranging from static documents to dynamic applications.

The scope of this specification does not include providing mechanisms for media-specific customization of presentation (although default rendering rules for Web browsers are included at the end of this specification, and several mechanisms for hooking into CSS are provided as part of the language).

The scope of this specification does not include documenting every HTML or DOM feature supported by Web browsers. Browsers support many features that are considered to be very bad for accessibility or that are otherwise inappropriate. For example, the blink element is clearly presentational and authors wishing to cause text to blink should instead use CSS.

The scope of this specification is not to describe an entire operating system. In particular, hardware configuration software, image manipulation tools, and applications that users would be expected to use with high-end workstations on a daily basis are out of scope. In terms of applications, this specification is targeted specifically at applications that would be expected to be used by users on an occasional basis, or regularly but from disparate locations, with low CPU requirements. For instance online purchasing systems, searching systems, games (especially multiplayer online games), public telephone books or address books, communications software (e-mail clients, instant messaging clients, discussion software), document editing software, etc.

For sophisticated cross-platform applications, there already exist several proprietary solutions (such as Mozilla's XUL, Adobe's Flash, or Microsoft's Silverlight). These solutions are evolving faster than any standards process could follow, and the requirements are evolving even faster. These systems are also significantly more complicated to specify, and are orders of magnitude more difficult to achieve interoperability with, than the solutions described in this document. Platform-specific solutions for such sophisticated applications (for example the Mac OS X Core APIs) are even further ahead.

1.3 History

Work on HTML5 originally started in late 2003, as a proof of concept to show that it was possible to extend HTML4's forms to provide many of the features that XForms 1.0 introduced, without requiring browsers to implement rendering engines that were incompatible with existing HTML Web pages. At this early stage, while the draft was already publicly available, and input was already being solicited from all sources, the specification was only under Opera Software's copyright.

In early 2004, some of the principles that underly this effort, as well as an early draft proposal covering just forms-related features, were presented to the W3C jointly by Mozilla and Opera at a workshop discussing the future of Web Applications on the Web. The proposal was rejected on the grounds that the proposal conflicted with the previously chosen direction for the Web's evolution.

Shortly thereafter, Apple, Mozilla, and Opera jointly announced their intent to continue working on the effort. A public mailing list was created, and the drafts were moved to the WHATWG site. The copyright was subsequently amended to be jointly owned by all three vendors, and to allow reuse of the specifications.

In 2006, the W3C expressed interest in the specification, and created a working group chartered to work with the WHATWG on the development of the HTML5 specifications. The working group opened in 2007. Apple, Mozilla, and Opera allowed the W3C to publish the specifications under the W3C copyright, while keeping versions with the less restrictive license on the WHATWG site.

Since then, both groups have been working together.

1.4 Relationships to other specifications

1.4.1 Relationship to HTML 4.01 and DOM2 HTML

This section is non-normative.

This specification represents a new version of HTML4, along with a new version of the associated DOM2 HTML API. Migration from HTML4 to the format and APIs described in this specification should in most cases be straightforward, as care has been taken to ensure that backwards-compatibility is retained. [HTML4] [DOM2HTML]

1.4.2 Relationship to XHTML 1.x

This section is non-normative.

This specification is intended to replace XHTML 1.0 as the normative definition of the XML serialization of the HTML vocabulary. [XHTML10]

While this specification updates the semantics and requirements of the vocabulary defined by XHTML Modularization 1.1 and used by XHTML 1.1, it does not attempt to provide a replacement for the modularization scheme defined and used by those (and other) specifications, and therefore cannot be considered a complete replacement for them. [XHTMLMOD] [XHTML11]

Thus, authors and implementors who do not need such a modularization scheme can consider this specification a replacement for XHTML 1.x, but those who do need such a mechanism are encouraged to continue using the XHTML 1.1 line of specifications.

1.4.3 Relationship to XHTML2 and XForms

This section is non-normative.

XHTML2 defines a new vocabulary with features for hyperlinks, multimedia content, annotating document edits, rich metadata, declarative interactive forms, and describing the semantics of human literary works such as poems and scientific papers. [XHTML2]

XForms similarly defines a new vocabulary with features for complex data entry, such as tax forms or insurance forms.

However, XHTML2 and XForms lack features to express the semantics of many of the non-document types of content often seen on the Web. For instance, they are not well-suited for marking up forum sites, auction sites, search engines, online shops, mapping applications, e-mail applications, word processors, real-time strategy games, and the like.

This specification aims to extend HTML so that it is also suitable in these contexts.

XHTML2, XForms, and this specification all use different namespaces and therefore can all be implemented in the same XML processor.

1.4.4 Relationship to XUL, Flash, Silverlight, and other proprietary UI languages

This section is non-normative.

This specification is independent of the various proprietary UI languages that various vendors provide. As an open, vendor-neutral language, HTML provides for a solution to the same problems without the risk of vendor lock-in.

1.5 HTML vs XHTML

This section is non-normative.

This specification defines an abstract language for describing documents and applications, and some APIs for interacting with in-memory representations of resources that use this language.

The in-memory representation is known as "DOM5 HTML", or "the DOM" for short.

There are various concrete syntaxes that can be used to transmit resources that use this abstract language, two of which are defined in this specification.

The first such concrete syntax is "HTML5". This is the format recommended for most authors. It is compatible with all legacy Web browsers. If a document is transmitted with the MIME type text/html , then it will be processed as an "HTML5" document by Web browsers.

The second concrete syntax uses XML, and is known as "XHTML5". When a document is transmitted with an XML MIME type, such as application/xhtml+xml , then it is processed by an XML processor by Web browsers, and treated as an "XHTML5" document. Authors are reminded that the processing for XML and HTML differs; in particular, even minor syntax errors will prevent an XML document from being rendered fully, whereas they would be ignored in the "HTML5" syntax.

The "DOM5 HTML", "HTML5", and "XHTML5" representations cannot all represent the same content. For example, namespaces cannot be represented using "HTML5", but they are supported in "DOM5 HTML" and "XHTML5". Similarly, documents that use the noscript feature can be represented using "HTML5", but cannot be represented with "XHTML5" and "DOM5 HTML". Comments that contain the string " --> " can be represented in "DOM5 HTML" but not in "HTML5" and "XHTML5". And so forth.

1.6 Structure of this specification

This section is non-normative.

This specification is divided into the following major sections:

Common Infrastructure
The conformance classes, algorithms, definitions, and the common underpinnings of the rest of the specification.
The DOM
Documents are built from elements. These elements form a tree using the DOM. This section defines the features of this DOM, as well as introducing the features common to all elements, and the concepts used in defining elements.
Elements
Each element has a predefined meaning, which is explained in this section. User agent requirements for how to handle each element are also given, along with rules for authors on how to use the element.
Web Browsers
HTML documents do not exist in a vacuum — this section defines many of the features that affect environments that deal with multiple pages, links between pages, and running scripts.
User Interaction
HTML documents can provide a number of mechanisms for users to interact with and modify content, which are described in this section.
The Communication APIs
Applications written in HTML often require mechanisms to communicate with remote servers, as well as communicating with other applications from different domains running on the same client.
Repetition Templates
A mechanism to support repeating sections in forms.
The Language Syntax
All of these features would be for naught if they couldn't be represented in a serialized form and sent to other people, and so this section defines the syntax of HTML, along with rules for how to parse HTML.

There are also a couple of appendices, defining rendering rules for Web browsers and listing areas that are out of scope for this specification.

1.6.1 How to read this specification

This specification should be read like all other specifications. First, it should be read cover-to-cover, multiple times. Then, it should be read backwards at least once. Then it should be read by picking random sections from the contents list and following all the cross-references.

1.6.2 Typographic conventions

This is a definition, requirement, or explanation.

This is a note.

This is an example.

This is an open issue.

This is a warning.

The defining instance of a term is marked up like this . Uses of that term are marked up like this or like this .

The defining instance of an element, attribute, or API is marked up like this . References to that element, attribute, or API are marked up like this .

Other code fragments are marked up like this .

Variables are marked up like this .

interface Example {
  // this is an IDL definition
};

2 Common infrastructure

2.1 Terminology

This specification refers to both HTML and XML attributes and DOM attributes, often in the same context. When it is not clear which is being referred to, they are referred to as content attributes for HTML and XML attributes, and DOM attributes for those from the DOM. Similarly, the term "properties" is used for both ECMAScript object properties and CSS properties. When these are ambiguous they are qualified as object properties and CSS properties respectively.

The term HTML documents is sometimes used in contrast with XML documents to specifically mean documents that were parsed using an HTML parser (as opposed to using an XML parser or created purely through the DOM).

Generally, when the specification states that a feature applies to HTML or XHTML, it also includes the other. When a feature specifically only applies to one of the two languages, it is called out by explicitly stating that it does not apply to the other format, as in "for HTML, ... (this does not apply to XHTML)".

This specification uses the term document to refer to any use of HTML, ranging from short static documents to long essays or reports with rich multimedia, as well as to fully-fledged interactive applications.

For simplicity, terms such as shown , displayed , and visible might sometimes be used when referring to the way a document is rendered to the user. These terms are not meant to imply a visual medium; they must be considered to apply to other media in equivalent ways.

Some of the algorithms in this specification, for historical reasons, require the user agent to pause until some condition has been met. While a user agent is paused, it must ensure that no scripts execute (e.g. no event handlers, no timers, etc). User agents should remain responsive to user input while paused, however, albeit without letting the user interact with Web pages where that would involve invoking any script.

2.1.1 XML

To ease migration from HTML to XHTML, UAs conforming to this specification will place elements in HTML in the http://www.w3.org/1999/xhtml namespace, at least for the purposes of the DOM and CSS. The term " elements in the HTML namespace ", or " HTML elements " for short, when used in this specification, thus refers to both HTML and XHTML elements.

Unless otherwise stated, all elements defined or mentioned in this specification are in the http://www.w3.org/1999/xhtml namespace, and all attributes defined or mentioned in this specification have no namespace (they are in the per-element partition).

When an XML name, such as an attribute or element name, is referred to in the form prefix : localName , as in xml:id or svg:rect , it refers to a name with the local name localName and the namespace given by the prefix, as defined by the following table:

xml
http://www.w3.org/XML/1998/namespace
html
http://www.w3.org/1999/xhtml
svg
http://www.w3.org/2000/svg

Attribute names are said to be XML-compatible if they match the Name production defined in XML, they contain no U+003A COLON (:) characters, and their first three characters are not an ASCII case-insensitive match for the string " xml ". [XML]

2.1.2 DOM trees

The term root element , when not explicitly qualified as referring to the document's root element, means the furthest ancestor element node of whatever node is being discussed, or the node itself if it has no ancestors. When the node is a part of the document, then that is indeed the document's root element; however, if the node is not currently part of the document tree, the root element will be an orphaned node.

An element is said to have been inserted into a document when its root element changes and is now the document's root element .

The term tree order means a pre-order, depth-first traversal of DOM nodes involved (through the parentNode / childNodes relationship).

When it is stated that some element or attribute is ignored , or treated as some other value, or handled as if it was something else, this refers only to the processing of the node after it is in the DOM. A user agent must not mutate the DOM in such situations.

The term text node refers to any Text node, including CDATASection nodes; specifically, any Node with node type TEXT_NODE (3) or CDATA_SECTION_NODE (4). [DOM3CORE]

2.1.3 Scripting

The construction "a Foo object", where Foo is actually an interface, is sometimes used instead of the more accurate "an object implementing the interface Foo ".

A DOM attribute is said to be getting when its value is being retrieved (e.g. by author script), and is said to be setting when a new value is assigned to it.

If a DOM object is said to be live , then that means that any attributes returning that object must always return the same object (not a new object each time), and the attributes and methods on that object must operate on the actual underlying data, not a snapshot of the data.

The terms fire and dispatch are used interchangeably in the context of events, as in the DOM Events specifications. [DOM3EVENTS]

2.1.4 Plugins

The term plugin is used to mean any content handler, typically a third-party content handler, for Web content types that are not supported by the user agent natively, or for content types that do not expose a DOM, that supports rendering the content as part of the user agent's interface.

One example of a plugin would be a PDF viewer that is instantiated in a browsing context when the user navigates to a PDF file. This would count as a plugin regardless of whether the party that implemented the PDF viewer component was the same as that which implemented the user agent itself. However, a PDF viewer application that launches separate from the user agent (as opposed to using the same interface) is not a plugin by this definition.

This specification does not define a mechanism for interacting with plugins, as it is expected to be user-agent- and platform-specific. Some UAs might opt to support a plugin mechanism such as the Netscape Plugin API; others might use remote content converters or have built-in support for certain types. [NPAPI]

Browsers should take extreme care when interacting with external content intended for plugins . When third-party software is run with the same privileges as the user agent itself, vulnerabilities in the third-party software become as dangerous as those in the user agent.

2.1.5 Character encodings

An ASCII-compatible character encoding is one that is a superset of US-ASCII (specifically, ANSI_X3.4-1968) for bytes in the set 0x09, 0x0A, 0x0C, 0x0D, 0x20 - 0x22, 0x26, 0x27, 0x2C - 0x3F, 0x41 - 0x5A, and 0x61 - 0x7A

2.2 Conformance requirements

All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.

The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC2119. For readability, these words do not appear in all uppercase letters in this specification. [RFC2119]

Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.

This specification describes the conformance criteria for user agents (relevant to implementors) and documents (relevant to authors and authoring tool implementors).

There is no implied relationship between document conformance requirements and implementation conformance requirements. User agents are not free to handle non-conformant documents as they please; the processing model described in this specification applies to implementations regardless of the conformity of the input documents.

User agents fall into several (overlapping) categories with different conformance requirements.

Web browsers and other interactive user agents

Web browsers that support XHTML must process elements and attributes from the HTML namespace found in XML documents as described in this specification, so that users can interact with them, unless the semantics of those elements have been overridden by other specifications.

A conforming XHTML processor would, upon finding an XHTML script element in an XML document, execute the script contained in that element. However, if the element is found within an XSLT transformation sheet (assuming the UA also supports XSLT), then the processor would instead treat the script element as an opaque element that forms part of the transform.

Web browsers that support HTML must process documents labeled as text/html as described in this specification, so that users can interact with them.

Non-interactive presentation user agents

User agents that process HTML and XHTML documents purely to render non-interactive versions of them must comply to the same conformance criteria as Web browsers, except that they are exempt from requirements regarding user interaction.

Typical examples of non-interactive presentation user agents are printers (static UAs) and overhead displays (dynamic UAs). It is expected that most static non-interactive presentation user agents will also opt to lack scripting support .

A non-interactive but dynamic presentation UA would still execute scripts, allowing forms to be dynamically submitted, and so forth. However, since the concept of "focus" is irrelevant when the user cannot interact with the document, the UA would not need to support any of the focus-related DOM APIs.

User agents with no scripting support

Implementations that do not support scripting (or which have their scripting features disabled entirely) are exempt from supporting the events and DOM interfaces mentioned in this specification. For the parts of this specification that are defined in terms of an events model or in terms of the DOM, such user agents must still act as if events and the DOM were supported.

Scripting can form an integral part of an application. Web browsers that do not support scripting, or that have scripting disabled, might be unable to fully convey the author's intent.

Conformance checkers

Conformance checkers must verify that a document conforms to the applicable conformance criteria described in this specification. Automated conformance checkers are exempt from detecting errors that require interpretation of the author's intent (for example, while a document is non-conforming if the content of a blockquote element is not a quote, conformance checkers running without the input of human judgement do not have to check that blockquote elements only contain quoted material).

Conformance checkers must check that the input document conforms when parsed without a browsing context (meaning that no scripts are run, and that the parser's scripting flag is disabled), and should also check that the input document conforms when parsed with a browsing context in which scripts execute, and that the scripts never cause non-conforming states to occur other than transiently during script execution itself. (This is only a "SHOULD" and not a "MUST" requirement because it has been proven to be impossible. [HALTINGPROBLEM] )

The term "HTML5 validator" can be used to refer to a conformance checker that itself conforms to the applicable requirements of this specification.

XML DTDs cannot express all the conformance requirements of this specification. Therefore, a validating XML processor and a DTD cannot constitute a conformance checker. Also, since neither of the two authoring formats defined in this specification are applications of SGML, a validating SGML system cannot constitute a conformance checker either.

To put it another way, there are three types of conformance criteria:

  1. Criteria that can be expressed in a DTD.
  2. Criteria that cannot be expressed by a DTD, but can still be checked by a machine.
  3. Criteria that can only be checked by a human.

A conformance checker must check for the first two. A simple DTD-based validator only checks for the first class of errors and is therefore not a conforming conformance checker according to this specification.

Data mining tools

Applications and tools that process HTML and XHTML documents for reasons other than to either render the documents or check them for conformance should act in accordance to the semantics of the documents that they process.

A tool that generates document outlines but increases the nesting level for each paragraph and does not increase the nesting level for each section would not be conforming.

Authoring tools and markup generators

Authoring tools and markup generators must generate conforming documents. Conformance criteria that apply to authors also apply to authoring tools, where appropriate.

Authoring tools are exempt from the strict requirements of using elements only for their specified purpose, but only to the extent that authoring tools are not yet able to determine author intent.

For example, it is not conforming to use an address element for arbitrary contact information; that element can only be used for marking up contact information for the author of the document or section. However, since an authoring tool is likely unable to determine the difference, an authoring tool is exempt from that requirement.

In terms of conformance checking, an editor is therefore required to output documents that conform to the same extent that a conformance checker will verify.

When an authoring tool is used to edit a non-conforming document, it may preserve the conformance errors in sections of the document that were not edited during the editing session (i.e. an editing tool is allowed to round-trip erroneous content). However, an authoring tool must not claim that the output is conformant if errors have been so preserved.

Authoring tools are expected to come in two broad varieties: tools that work from structure or semantic data, and tools that work on a What-You-See-Is-What-You-Get media-specific editing basis (WYSIWYG).

The former is the preferred mechanism for tools that author HTML, since the structure in the source information can be used to make informed choices regarding which HTML elements and attributes are most appropriate.

However, WYSIWYG tools are legitimate. WYSIWYG tools should use elements they know are appropriate, and should not use elements that they do not know to be appropriate. This might in certain extreme cases mean limiting the use of flow elements to just a few elements, like div , b , i , and span and making liberal use of the style attribute.

All authoring tools, whether WYSIWYG or not, should make a best effort attempt at enabling users to create well-structured, semantically rich, media-independent content.

Some conformance requirements are phrased as requirements on elements, attributes, methods or objects. Such requirements fall into two categories: those describing content model restrictions, and those describing implementation behavior. The former category of requirements are requirements on documents and authoring tools. The second category are requirements on user agents.

Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.)

User agents may impose implementation-specific limits on otherwise unconstrained inputs, e.g. to prevent denial of service attacks, to guard against running out of memory, or to work around platform-specific limitations.

For compatibility with existing content and prior specifications, this specification describes two authoring formats: one based on XML (referred to as XHTML5 ), and one using a custom format inspired by SGML (referred to as HTML5 ). Implementations may support only one of these two formats, although supporting both is encouraged.

XHTML documents ( XML documents using elements from the HTML namespace ) that use the new features described in this specification and that are served over the wire (e.g. by HTTP) must be sent using an XML MIME type such as application/xml or application/xhtml+xml and must not be served as text/html . [RFC3023]

Such XML documents may contain a DOCTYPE if desired, but this is not required to conform to this specification.

According to the XML specification, XML processors are not guaranteed to process the external DTD subset referenced in the DOCTYPE. This means, for example, that using entity references for characters in XHTML documents is unsafe (except for < , > , & , " and ' ).

HTML documents , if they are served over the wire (e.g. by HTTP) must be labeled with the text/html MIME type.

The language in this specification assumes that the user agent expands all entity references, and therefore does not include entity reference nodes in the DOM. If user agents do include entity reference nodes in the DOM, then user agents must handle them as if they were fully expanded when implementing this specification. For example, if a requirement talks about an element's child text nodes, then any text nodes that are children of an entity reference that is a child of that element would be used as well. Entity references to unknown entities must be treated as if they contained just an empty text node for the purposes of the algorithms defined in this specification.

2.2.1 Dependencies

This specification relies on several other underlying specifications.

XML

Implementations that support XHTML5 must support some version of XML, as well as its corresponding namespaces specification, because XHTML5 uses an XML serialization with namespaces. [XML] [XMLNAMES]

DOM

The Document Object Model (DOM) is a representation — a model — of a document and its content. The DOM is not just an API; the conformance criteria of HTML implementations are defined, in this specification, in terms of operations on the DOM. [DOM3CORE]

Implementations must support some version of DOM Core and DOM Events, because this specification is defined in terms of the DOM, and some of the features are defined as extensions to the DOM Core interfaces. [DOM3CORE] [DOM3EVENTS]

ECMAScript

Implementations that use ECMAScript to implement the APIs defined in this specification must implement them in a manner consistent with the ECMAScript Bindings defined in the Web IDL specification, as this specification uses that specification's terminology. [WebIDL]

Media Queries

Implementations must support some version of the Media Queries language. [MQ]

This specification does not require support of any particular network transport protocols, style sheet language, scripting language, or any of the DOM and WebAPI specifications beyond those described above. However, the language described by this specification is biased towards CSS as the styling language, ECMAScript as the scripting language, and HTTP as the network protocol, and several features assume that those languages and protocols are in use.

This specification might have certain additional requirements on character encodings, image formats, audio formats, and video formats in the respective sections.

2.2.2 Features defined in other specifications

this section will be removed at some point

Some elements are defined in terms of their DOM textContent attribute. This is an attribute defined on the Node interface in DOM3 Core. [DOM3CORE]

The interface DOMTimeStamp is defined in DOM3 Core. [DOM3CORE]

The rules for handling alternative style sheets are defined in the CSS object model specification. [CSSOM]

See http://dev.w3.org/cvsweb/~checkout~/csswg/cssom/Overview.html?content-type=text/html;%20charset=utf-8

2.2.3 Common conformance requirements for APIs exposed to JavaScript

This section will eventually be removed in favour of WebIDL.

A lot of arrays/lists/ collection s in this spec assume zero-based indexes but use the term " index th" liberally. We should define those to be zero-based and be clearer about this.

Unless otherwise specified, if a DOM attribute that is a floating point number type ( float ) is assigned an Infinity or Not-a-Number value, a NOT_SUPPORTED_ERR exception must be raised.

Unless otherwise specified, if a method with an argument that is a floating point number type ( float ) is passed an Infinity or Not-a-Number value, a NOT_SUPPORTED_ERR exception must be raised.

Unless otherwise specified, if a method is passed fewer arguments than is defined for that method in its IDL definition, a NOT_SUPPORTED_ERR exception must be raised.

Unless otherwise specified, if a method is passed more arguments than is defined for that method in its IDL definition, the excess arguments must be ignored.

2.3 Case-sensitivity

This specification defines several comparison operators for strings.

Comparing two strings in a case-sensitive manner means comparing them exactly, codepoint for codepoint.

Comparing two strings in a ASCII case-insensitive manner means comparing them exactly, codepoint for codepoint, except that the characters in the range U+0041 .. U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) and the corresponding characters in the range U+0061 .. U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z) are considered to also match.

Comparing two strings in a compatibility caseless manner means using the Unicode compatibility caseless match operation to compare the two strings. [UNICODECASE]

Converting a string to uppercase means replacing all characters in the range U+0061 .. U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z) with the corresponding characters in the range U+0041 .. U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z).

Converting a string to lowercase means replacing all characters in the range U+0041 .. U+005A (i.e. LATIN CAPITAL LETTER A to LATIN CAPITAL LETTER Z) with the corresponding characters in the range U+0061 .. U+007A (i.e. LATIN SMALL LETTER A to LATIN SMALL LETTER Z).

2.4 Common microsyntaxes

There are various places in HTML that accept particular data types, such as dates or numbers. This section describes what the conformance criteria for content in those formats is, and how to parse them.

Need to go through the whole spec and make sure all the attribute values are clearly defined either in terms of microsyntaxes or in terms of other specs, or as "Text" or some such.

2.4.1 Common parser idioms

The space characters , for the purposes of this specification, are U+0020 SPACE, U+0009 CHARACTER TABULATION (tab), U+000A LINE FEED (LF), U+000C FORM FEED (FF), and U+000D CARRIAGE RETURN (CR).

The White_Space characters are those that have the Unicode property "White_Space". [UNICODE]

Some of the micro-parsers described below follow the pattern of having an input variable that holds the string being parsed, and having a position variable pointing at the next character to parse in input .

For parsers based on this pattern, a step that requires the user agent to collect a sequence of characters means that the following algorithm must be run, with characters being the set of characters that can be collected:

  1. Let input and position be the same variables as those of the same name in the algorithm that invoked these steps.

  2. Let result be the empty string.

  3. While position doesn't point past the end of input and the character at position is one of the characters , append that character to the end of result and advance position to the next character in input .

  4. Return result .

The step skip whitespace means that the user agent must collect a sequence of characters that are space characters . The step skip White_Space characters means that the user agent must collect a sequence of characters that are White_Space characters. In both cases, the collected characters are not used. [UNICODE]

2.4.2 Boolean attributes

A number of attributes in HTML5 are boolean attributes . The presence of a boolean attribute on an element represents the true value, and the absence of the attribute represents the false value.

If the attribute is present, its value must either be the empty string or a value that is an ASCII case-insensitive match for the attribute's canonical name, with no leading or trailing whitespace.

2.4.3 Numbers

2.4.3.1 Unsigned integers

A string is a valid non-negative integer if it consists of one of more characters in the range U+0030 DIGIT ZERO (0) to U+0039 DIGIT NINE (9).

The rules for parsing non-negative integers are as given in the following algorithm. When invoked, the steps must be followed in the order given, aborting at the first step that returns a value. This algorithm will either return zero, a positive integer, or an error. Leading spaces are ignored. Trailing spaces and indeed any trailing garbage characters are ignored.

  1. Let input be the string being parsed.

  2. Let position be a pointer into input , initially pointing at the start of the string.

  3. Let value have the value 0.

  4. Skip whitespace .

  5. If position is past the end of input , return an error.

  6. If the next character is not one of U+0030 DIGIT ZERO (0) .. U+0039 DIGIT NINE (9), then return an error.

  7. If the next character is one of U+0030 DIGIT ZERO (0) .. U+0039 DIGIT NINE (9):

    1. M