Several attributes have been introduced to various elements that were already part of HTML4:
areaelements now have a
mediaattribute for consistency with the
linkelement. WHATWG HTML also has the
areaelement, for consistency with the
linkelements, now also has the
baseelement can now have a
targetattribute as well, mainly for consistency with the
aelement. (This is already widely supported.)
metaelement has a
charsetattribute now as this was already widely supported and provides a nice way to specify the character encoding for the document.
- A new
autofocusattribute can be specified on the
input(except when the
buttonelements. It provides a declarative way to focus a form control during page load. Using this feature should enhance the user experience compared to focusing the element with script as the user can turn it off if the user does not like it, for instance.
- A new
placeholderattribute can be specified on the
textareaelements. It represents a hint intended to aid the user with data entry.
<input type=email placeholder="email@example.com">
- The new
fieldsetelements allows for controls to be associated with a form. These elements can now be placed anywhere on a page, not just as descendants of the
formelement, and still be associated with a
<table> <tr> <th>Key <th>Value <th>Action <tr> <td><form id=1><input name=1-key></form> <td><input form=1 name=1-value> <td><button form=1 name=1-action value=save>✓</button> <button form=1 name=1-action value=delete>✗</button> ... </table>
- The new
requiredattribute applies to
input(except when the
imageor some button type such as
textarea. It indicates that the user has to fill in a value in order to submit the form. For
select, the first
optionelement has to be a placeholder with an empty value.
<label>Color: <select name=color required> <option value="">Choose one <option>Red <option>Green <option>Blue </select></label>
fieldsetelement now allows the
disabledattribute which disables all descendant controls (excluding those that are descendants of the
legendelement) when specified, and the
nameattribute which can be used for script access.
inputelement has several new attributes to specify constraints:
step. As mentioned before it also has a new
listattribute which can be used together with the
datalistelement. It also now has the
heightattributes to specify the dimensions of the image when using
textareaelements have a new attribute named
dirnamethat causes the directionality of the control as set by the user to be submitted as well.
textareaelement also has two new attributes,
wrapwhich control max input length and submitted line wrapping behavior, respectively.
formelement has a
novalidateattribute that can be used to disable form validation submission (i.e. the form can always be submitted).
formtargetas new attributes. If present, they override the
targetattributes on the
- In WHATWG HTML, the
menuelement has two new attributes:
label. They allow the element to transform into a menu as found in typical user interfaces as well as providing for context menus in conjunction with the global
styleelement has a new
scopedattribute which can be used to enable scoped style sheets. Style rules within such a
styleelement only apply to the local tree.
scriptelement has a new attribute called
asyncthat influences script loading and execution.
htmlelement has a new attribute called
manifestthat points to an application cache manifest used in conjunction with the API for offline Web applications.
linkelement has a new attribute called
sizes. It can be used in conjunction with the
iconrelationship (set through the
relattribute; can be used for e.g. favicons) to indicate the size of the referenced icon. Thus allowing for icons of distinct dimensions.
olelement has a new attribute called
reversed. When present, it indicates that the list order is descending.
iframeelement has three new attributes called
srcdocwhich allow for sandboxing content, e.g. blog comments.
objectelement has a new attribute called
typemustmatchwhich allows safer embedding of external resources.
imgelement has a new attribute called
crossoriginto use CORS in the fetch and if it is successful, allows the image data to be read with the
canvasAPI. In WHATWG HTML, there is also a new attribute called
srcsetto support multiple images for different resolutions and different images for different viewport sizes.
Several attributes from HTML4 now apply to all elements. These are called global attributes:
title. Additionally, XHTML 1.0 only allowed
xml:space on some elements, which is now allowed on all elements in XHTML documents.
There are also several new global attributes:
contenteditableattribute indicates that the element is an editable area. The user can change the contents of the element and manipulate the markup.
contextmenuattribute can be used to point to a context menu provided by the author.
data-*collection of author-defined attributes. Authors can define any attribute they want as long as they prefix it with
data-to avoid clashes with future versions of HTML. These are intended to be used to store custom data to be consumed by the Web page or application itself. They are not intended for data to be consumed by other parties (e.g. user agents).
dropzoneattributes can be used together with the new drag & drop API.
hiddenattribute indicates that an element is not yet, or is no longer, relevant.
- WHATWG HTML has the
inertattribute, intended to make
aria-*collection attributes which can be used to instruct assistive technology.
spellcheckattribute allows for hinting whether content can be checked for spelling or not.
translateattribute gives a hint to translators whether the content should be translated.
HTML5 also makes all event handler attributes from HTML4, which take the form
onevent, global attributes and adds several new event handler attributes for new events it defines. For instance, the
onplay event handler attribute for the
play event which is used by the API for the media elements (