A user account is required in order to edit this wiki, but we've had to disable public user registrations due to spam.

To request an account, ask an autoconfirmed user on Chat (such as one of these permanent autoconfirmed members).

Changes from HTML4: Difference between revisions

From WHATWG Wiki
Jump to navigation Jump to search
m (→‎Character Encoding: fix heading levels)
(Moved to "Differences from HTML4")
 
(17 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Global overview ==
#REDIRECT [[Differences from HTML4]]
 
HTML5 is different from HTML4 in a way that it addresses both document and application semantics making it more suitable for the web applications created today. HTML5 also reflects implementations better where they differ from HTML4 to ensure the language is implementable and compatible with the web. Inspired by the forward compatible error handling in CSS HTML5 defines detailed processing models where necessary to ensure that implementations become interoperable and that the language stays extensible in the future.
 
HTML5 also integrates DOM Level 2 HTML so the element specific APIs are defined along with the rest of the language. Because the language is mostly defined in terms of the DOM it's very easy to get an XML serialization as well. This XML serialization is called XHTML5 and is basically an update to XHTML1.x.
 
== Syntax ==
 
; Writing HTML5: HTML5 specifies its own syntax rules authors have to follow. These syntax rules are compatible with the XHTML syntax rules althoug this does not imply that parsing such a document with an HTML parser will give the same result as parsing it with an XML parser.
; Parsing HTML5: HTML5 defines its own parsing rules (including "error correction") for text/html resources and no longer assumes SGML features are supported.
 
== New elements ==
 
=== Document Structure ===
 
* article
* aside
* dialog
* figure
* footer
* header
* nav
* section
 
=== Data ===
 
* audio
* embed
* m
* meter
* source
* time
* video
 
=== Applications ===
 
* canvas
* command
* datagrid
* details
* datalist (Web Forms 2)
* event-source
* output (Web Forms 2)
* progress
 
== Changed elements ==
 
These elements have a new meaning in HTML5 which is incompatible with HTML4. The new meaning better reflects the way they are used on the web or gives them a purpose so people can start using them.
 
; b: represents a span of text to be stylistically offset from the normal prose without conveying any extra importance, such as key words in a document abstract, product names in a review, or other spans of text whose typical typographic presentation is boldened
; hr: represents a paragraph-level thematic break
; i: represents a span of text in an alternate voice or mood, or otherwise offset from the normal prose, such as a taxonomic designation, a technical term, an idiomatic phrase from another language, a thought, a ship name, or some other prose whose typical typographic presentation is italicized
; menu: redefined to be useful for actual menu's
; small: small print (for side comments and legal print)
; strong: represents importance rather than strong emphasis
 
== Dropped Elements ==
 
That these elements are dropped means that authors are no longer allowed to use them. User agents will still have to support them and HTML5 will probably get a rendering section in due course that says exactly how. (isindex for instance is already supported by the parser.)
 
* acronym (use abbr instead)
* applet (use object instead)
* basefont
* big
* center
* dir
* font (allowed when inserted by WYSIWYG editors)
* frame
* frameset
* isindex
* noframes
* noscript (only dropped in XHTML5)
* s
* strike
* tt
* u
 
== Dropped Attributes ==
 
Some attributes that were defined in HTML4 are not included in HTML5. Here's a current list (subject to change, see the spec):
 
<table>
<tr><th>Element</th><th>Attributes</th></tr>
<tr> <td>html</td> <td>version</td></tr>
<tr> <td>head</td> <td>profile</td> </tr>
<tr> <td>meta</td> <td>scheme</td> </tr>
<tr> <td>a</td> <td>rev, charset</td> </tr>
<tr> <td>link</td> <td>rev, target, charset</td> </tr>
<tr> <td>form</td> <td>target</td> </tr>
<tr> <td>script</td> <td>charset</td> </tr>
<tr> <td>table</td> <td>summary</td> </tr>
<tr> <td>td, th</td> <td>headers, axis</td> </tr>
<tr> <td>object</td> <td>archive, standby</td> </tr>
<tr> <td>param</td> <td>valuetype</td> </tr>
</table>
 
In addition, HTML5 has none of the presentational attributes that were in HTML4 (including those on &lt;table&gt;. Any attributes defined on ''elements'' that are not in HTML5 are (obviously) also not in HTML5.
 
== Character Encoding ==
 
The character encoding can be declared using the meta element, but the syntax of the meta element has changed.  In HTML 4.01 and earlier, the meta element was:
 
&lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
 
In HTML5, the syntax was simplified to remove the unnecessary markup, yet still remain compatible with the encoding detection implemented in most existing browsers.
 
&lt;meta charset="UTF-8"&gt;
 
=== HTML 4 Algorithm ===
 
Source [http://www.w3.org/TR/html4/charset.html#h-5.2.2 5.2.2 Specifying the character encoding], HTML 4.01 Specification.
 
# An HTTP "charset" parameter in a "Content-Type" field.
# A META declaration with "http-equiv" set to "Content-Type" and a value set for "charset".
# The charset attribute set on an element that designates an external resource.
 
=== HTML 5 Algorithm ===
 
The exact algorithm that browsers must follow in order to [http://www.whatwg.org/specs/web-apps/current-work/#the-input0 determine the character encoding] is specified in HTML 5.  The basic algorithm works as follows:
 
# If the transport layer specifies an encoding, use that, and abort these steps. (e.g. The HTTP Content-Type header).
# Read the first 512 bytes of the file, or at least as much as possible if less than that.
# If the file starts with a UTF-8, UTF-16 or UTF-32 BOM, then use that and abort these steps.
# Otherwise use the special algorithm to search the first 512 bytes for a meta element that declares the encoding.  The algorithm is relatively lenient in what it will detect, though since it doesn't use the normal parsing algorithm, there are some restrictions.

Latest revision as of 13:44, 9 May 2007