This document outlines the major element differences between HTML4 and HTML5. For a full view of all the changes, see the W3C’s document “HTML5 Differences from HTML4” at www.w3.org/TR/html5-diff/.
The following list represents all the new elements introduced in HTML5. For descriptions of these elements, see Appendix B, “HTML Element Reference”:
The input element’s type attribute now has the following new values. For descriptions of these elements, see Appendix B, “HTML Element Reference”:
Many new attributes have been added to existing elements. These new attributes either are existing attributes added to new elements or are completely new attributes. These are also covered in depth alongside their elements in Appendix B, “HTML Element Reference”:
Element | Attributes |
<a> | media |
<area> | hreflang, media, rel, type |
<base> | target |
<button> | autofocus,form, formaction, formenctype, formmethod, formnovalidate, formtarget |
<fieldset> | disabled, form, name |
<form> | novalidate |
<html> | manifest |
<iframe> | sandbox, seamless, srcdoc |
<img> | crossorigin |
<input> | autocomplete, autofocus, dirname, form,formaction, formenctype, formmethod, formnovalidate, formtarget list,max,min, multiple,pattern,placeholder, required, step, height, width |
<label> | form |
<link> | sizes |
<menu> | label, type |
<meta> | charset |
<object> | form, typemustmatch |
<ol> | reversed |
<output> | form |
<script> | async |
<select> | autofocus, form,required |
<style> | scoped |
<textarea> | autofocus, form,maxlength,placeholder,required,wrap, dirname |
HTML5 greatly expands on the number of global attributes. The following list includes all the new global attributes and the global attributes present in previous versions of HTML:
Several existing attributes have had their meanings changed:
Attribute | Element | Change |
accept | <input> | audio/*, video/*, and image/* are now valid values. |
accesskey | global | Now allows multiple characters to be specified. |
action | <form> | No longer allowed to have an empty URL. |
colspan | <td><th> | Now has to be greater than zero. |
coords | <area> | No longer allows a percentage value of the radius when the element is a circle. |
data | <object> | No longer relative to the codebase. |
defer | <script> | Explicitly executes the script when the page has finished parsing. |
dir | global | Now allows the value auto. |
enctype | <form> | Now supports the value text/plain. |
width/height | <img>, <iframe>, <object> | No longer allowed to contain percentages. No longer allowed to stretch the image to a different aspect ratio than its intrinsic aspect ratio. |
href | <link> | No longer allowed to have an empty URL. |
href | <base> | Allowed to contain a relative URL. |
Attributes that accept URLs | global | Now support IRIs if the document’s encoding is UTF-8 or UTF-16. |
http-equiv | <meta> | No longer said to be used by HTTP servers to create HTTP headers in the HTTP response. Instead, it is said to be a pragma directive to be used by the user agent. |
id | global | Now allowed to have any unique value, as long as it is not an empty string and does not contain spaces. |
lang | global | Takes the empty string in addition to a valid language identifier. |
media | <link> | Now accepts a media query. Defaults to “all.” |
Event handlers | global | Defaults to JavaScript as the scripting language. |
value | <li> | No longer deprecated. |
start/type | <ol> | No longer deprecated. |
style | global | Always uses CSS as the style language. |
tabindex | global | Allows negative values, which indicates that the element can receive focus but cannot be tabbed to. |
target | <a><area> | No longer deprecated. |
type | <script><style> | No longer required if the scripting language is JavaScript and the styling language is CSS, respectively. |
usemap | img | No longer takes a URL, but instead takes a valid hash-name reference to a map element. |
The elements in this section are no longer part of the HTML specification:
Some attributes from HTML4 are no longer allowed in HTML5:
Element | Attributes |
<a> | charset, coords, rev, shape |
<area> | nohref |
<body> | alink, background, bgcolor, link, text, vlink |
<br> | clear |
<caption> | align |
<col> | align, char, charoff, valign, width |
<colgroup> | align, char, charoff, valign, width |
<div> | align |
<dl> | Compact |
<head> | profile |
<hn> | align |
<hr> | align, noshade,size, width |
<html> | version |
<iframe> | align, frameborder, longdesc, marginheight, marginwidth, scrolling |
<img> | align, hspace, longdesc, name, vspace |
<input> | align |
<legend> | align |
<li> | type |
<link> | charset, rev, target |
<menu> | compact |
<meta> | scheme |
<object> | align, archive, border, classid, codebase, codetype, declare, space, standby, vspace, hspace |
<ol> | compact |
<p> | align |
<param> | type, valuetype |
<pre> | width |
<table> | align, bgcolor, cellpadding,cellspacing, rules, summary, width, frame |
<tbody> | align, char, charoff, valign |
<td> | abbr,align, axis, bgcolor char, charoff,height,nowrap, scope,valign, width |
<tfoot> | align char, charoff, valign |
<th> | abbr, align,axis, bgcolor char, charoff,height,nowrap, valign, width |
<thead> | align, char, charoff, valign |
<tfoot> | align, char, charoff, valign |
<tr> | align, bgcolor,char, charoff, valign |
<ul> | compact, type |
The following elements and attribute types are at risk of being removed from the specification: