html5 Cheat Sheet wc3 PDF
html5 Cheat Sheet wc3 PDF
html5 Cheat Sheet wc3 PDF
Ordered Alphabetically
New = New tags in HTML 5.
Tag Description
<!--...--> Defines a comment
<!DOCTYPE> Defines the document type
<a> Defines a hyperlink
<abbr> Defines an abbreviation
<acronym> Not supported in HTML 5.
<address> Defines an address element
<applet> Not supported in HTML 5.
<area> Defines an area inside an image map
<article>New Defines an article
email
url
number
range
Date pickers (date, month, week, time, datetime, datetime-local)
search
color
Browser Support
Input type IE Firefox Opera Chrome Safari
email No No 9.0 No No
url No No 9.0 No No
number No No 9.0 No No
range No No 9.0 4.0 4.0
Date pickers No No 9.0 No No
search No No No No No
color No No No No No
Note: Opera has the best support for the new input types. However, you can already start using them in all major browsers.
If they are not supported, they will be behave as regular text fields.
The value of the email field is automatically validated when the form is submitted.
Example
Try it yourself »
Tip: Safari on the iPhone recognizes the email input type, and changes the on-screen keyboard to match it (adds @ and
.com options).
The value of the url field is automatically validated when the form is submitted.
Example
Try it yourself »
Tip: Safari on the iPhone recognizes the url input type, and changes the on-screen keyboard to match it (adds .com option).
Example
Try it yourself »
Use the following attributes to specify restrictions for the number type:
Tip: Safari on the iPhone recognizes the number input type, and changes the on-screen keyboard to match it (shows
numbers).
Example
Try it yourself »
Use the following attributes to specify restrictions for the range type:
Example
Try it yourself »
datalist
keygen
output
Browser Support
Attribute IE Firefox Opera Chrome Safari
datalist No No 9.5 No No
keygen No No 10.5 3.0 No
output No No 9.5 No No
datalist Element
The datalist element specifies a list of options for an input field.
To bind a datalist to an input field, let the list attribute of the input field refer to the id of the datalist:
Example
Try it yourself »
keygen Element
The purpose of the keygen element is to provide a secure way to authenticate users.
The keygen element is a key-pair generator. When a form is submitted, two keys are generated, one private and one public.
The private key is stored on the client, and the public key is sent to the server. The public key could be used to generate a
client certificate to authenticate the user in the future.
Currently, the browser support for this element is not good enough to be a useful security standard.
Example
Try it yourself »
output Element
The output element is used for different types of output, like calculations or script output:
Example
Try it yourself »
autocomplete
novalidate
autocomplete
autofocus
form
form overrides (formaction, formenctype, formmethod, formnovalidate, formtarget)
height and width
list
min, max and step
multiple
pattern (regexp)
placeholder
required
Browser Support
Attribute IE Firefox Opera Chrome Safari
autocomplete 8.0 3.5 9.5 3.0 4.0
autofocus No No 10.0 3.0 4.0
form No No 9.5 No No
form overrides No No 10.5 No No
autocomplete Attribute
The autocomplete attribute specifies that the form or input field should have an autocomplete function.
Note: The autocomplete attribute works with <form>, and the following <input> types: text, search, url, telephone, email,
password, datepickers, range, and color.
When the user starts to type in an autocomplete field, the browser should display options to fill in the field:
Example
Try it yourself »
Note: In some browsers you may need to activate the autocomplete function for this to work.
autofocus Attribute
The autofocus attribute specifies that a field should automatically get focus when a page is loaded.
Example
Try it yourself »
form Attribute
The form attribute specifies one or more forms the input field belongs to.
The form attribute must refer to the id of the form it belongs to:
Example
Try it yourself »
Note: The form override attributes works with the following <input> types: submit and image.
Example
Try it yourself »
Note: These attributes are helpful for creating different submit buttons.
Example
Try it yourself »
list Attribute
The list attribute specifies a datalist for an input field. A datalist is a list of options for an input field.
Note: The list attribute works with the following <input> types: text, search, url, telephone, email, date pickers, number,
range, and color.
Example
Try it yourself »
The max attribute specifies the maximum value allowed for the input field.
The min attribute specifies the minimum value allowed for the input field.
The step attribute specifies the legal number intervals for the input field (if step="3", legal numbers could be -3,0,3,6, etc).
Note: The min, max, and step attributes works with the following <input> types: date pickers, number, and range.
The example below shows a numeric field that accepts values between 0 and 10, with a step of 3 (legal numbers are 0, 3, 6
and 9):
Example
Try it yourself »
multiple Attribute
The multiple attribute specifies that multiple values can be selected for an input field.
Note: The multiple attribute works with the following <input> types: email, and file.
Example
Try it yourself »
novalidate Attribute
The novalidate attribute specifies that the form or input field should not be validated when submitted.
Note: The novalidate attribute works with: <form> and the following <input> types: text, search, url, telephone, email,
password, date pickers, range, and color.
Example
Try it yourself »
pattern Attribute
The pattern attribute specifies a pattern used to validate an input field.
The pattern is a regular expression. You can read about this in our JavaScript tutorial.
Note: The pattern attribute works with the following <input> types: text, search, url, telephone, email, and password
The example below shows a text field that can only contain three letters (no numbers or special characters):
Example
Try it yourself »
placeholder Attribute
The placeholder attribute provides a hint that describes the expected value of an input field.
Note: The placeholder attribute works with the following <input> types: text, search, url, telephone, email, and password
The hint is displayed in the input field when it is empty, and disappears when the field gets focus:
Example
Try it yourself »
required Attribute
The required attribute specifies that an input field must be filled out before submitting.
Note: The required attribute works with the following <input> types: text, search, url, telephone, email, password, date
pickers, number, checkbox, radio, and file.
Example
Try it yourself »
data-yourvalueNew value Author defined attributes. Authors of a HTML document can define their own attributes.
Must start with "data-".
dir ltr Specifies the text direction for the content in an element.
rtl
draggableNew true Specifies whether or not a user is allowed to drag an element.
false
auto
hiddenNew hidden Specifies that the element is not relevant. Hidden elements are not displayed.
onunloadNew script Script to be run when the user leaves the document
Form Events
Events triggered by actions inside a HTML form.
Keybord Events
Events triggered by a keyboard.
Mouse Events
Events triggered by a mouse, or similar user actions:
ondragenterNew script Script to be run when an element has been dragged to a valid drop target
ondragleaveNew script Script to be run when an element leaves a valid drop target
ondragoverNew script Script to be run when an element is being dragged over a valid drop target
Applies to all HTML 5 elements, but is most common in media elements, such as audio, embed, img, object, and video:
oncanplaythroughNew script Script to be run when media can be played to the end, without stopping for buffering
ondurationchangeNew script Script to be run when the length of the media is changed
onemptiedNew script Script to be run when a media resource element suddenly becomes empty (network
errors, errors on load etc.)
onendedNew script Script to be run when media has reach the end
onerrorNew script Script to be run when an error occurs during the loading of an element
onloadedmetadataNew script Script to be run when the duration and other media data of a media element is loaded
onloadstartNew script Script to be run when the browser starts to load the media data
onplayNew script Script to be run when media data is going to start playing
onplayingNew script Script to be run when media data has start playing
onprogressNew script Script to be run when the browser is fetching the media data
onratechangeNew script Script to be run when the media data's playing rate has changed
onseekedNew script Script to be run when a media element's seeking attribute is no longer true, and the
seeking has ended
onseekingNew script Script to be run when a media element's seeking attribute is true, and the seeking has
begun
onstalledNew script Script to be run when there is an error in fetching media data (stalled)
onsuspendNew script Script to be run when the browser has been fetching media data, but stopped before the
entire media file was fetched
ontimeupdateNew script Script to be run when media changes its playing position
onvolumechangeNew script Script to be run when media changes the volume, also when volume is set to "mute"
onwaitingNew script Script to be run when media has stopped playing, but is expected to resume