Thursday, November 10, 2011
Wednesday, November 2, 2011
HTML5 Tutorial START
HTML5 Tutorial
HTML5 is the next generation of HTML.
This tutorial teaches you about the new features in HTML5.
This tutorial teaches you about the new features in HTML5.
Examples in Each Chapter
With our HTML editor, you can edit the HTML, and click on a button to view the result.Example
<!DOCTYPE HTML><html>
<body>
<video width="320" height="240" controls="controls">
<source src="movie.mp4" type="video/mp4" />
<source src="movie.ogg" type="video/ogg" />
<source src="movie.webm" type="video/webm" />
Your browser does not support the video tag.
</video>
</body>
HTML5 introduction
HTML5 is the next generation of HTML.
What is HTML5?
HTML5 will be the new standard for HTML, XHTML, and the HTML DOM.The previous version of HTML came in 1999. The web has changed a lot since then.
HTML5 is still a work in progress. However, most modern browsers have some HTML5 support.
How Did HTML5 Get Started?
HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the Web Hypertext Application Technology Working Group (WHATWG).WHATWG was working with web forms and applications, and W3C was working with XHTML 2.0. In 2006, they decided to cooperate and create a new version of HTML.
Some rules for HTML5 were established:
- New features should be based on HTML, CSS, DOM, and JavaScript
- Reduce the need for external plugins (like Flash)
- Better error handling
- More markup to replace scripting
- HTML5 should be device independent
- The development process should be visible to the public
New Features
Some of the most interesting new features in HTML5:- The canvas element for drawing
- The video and audio elements for media playback
- Better support for local offline storage
- New content specific elements, like article, footer, header, nav, section
- New form controls, like calendar, date, time, email, url, search
Browser Support
HTML5 is not yet an official standard, and no browsers have full HTML5 support.But all major browsers (Safari, Chrome, Firefox, Opera, Internet Explorer) continue to add new HTML5 features to their latest versions.
HTML5 New Elements
HTML5 New Elements
New Elements in HTML5
The internet has changed a lot since HTML 4.01 became a standard in 1999.Today, some elements in HTML 4.01 are obsolete, never used, or not used the way they were intended to. These elements are deleted or re-written in HTML5.
To better handle today's internet use, HTML5 also includes new elements for better structure, drawing, media content, and better form handling.
New Markup Elements
New elements for better structure:Tag | Description |
---|---|
<article> | Specifies independent, self-contained content, could be a news-article, blog post, forum post, or other articles which can be distributed independently from the rest of the site. |
<aside> | For content aside from the content it is placed in. The aside content should be related to the surrounding content |
<bdi> | For text that should not be bound to the text-direction of its parent elements |
<command> | A button, or a radiobutton, or a checkbox |
<details> | For describing details about a document, or parts of a document |
<summary> | A caption, or summary, inside the details element |
<figure> | For grouping a section of stand-alone content, could be a video |
<figcaption> | The caption of the figure section |
<footer> | For a footer of a document or section, could include the name of the author, the date of the document, contact information, or copyright information |
<header> | For an introduction of a document or section, could include navigation |
<hgroup> | For a section of headings, using <h1> to <h6>, where the largest is the main heading of the section, and the others are sub-headings |
<mark> | For text that should be highlighted |
<meter> | For a measurement, used only if the maximum and minimum values are known |
<nav> | For a section of navigation |
<progress> | The state of a work in progress |
<ruby> | For ruby annotation (Chinese notes or characters) |
<rt> | For explanation of the ruby annotation |
<rp> | What to show browsers that do not support the ruby element |
<section> | For a section in a document. Such as chapters, headers, footers, or any other sections of the document |
<time> | For defining a time or a date, or both |
<wbr> | Word break. For defining a line-break opportunity. |
New Media Elements
HTML5 provides a new standard for media content:Tag | Description |
---|---|
<audio> | For multimedia content, sounds, music or other audio streams |
<video> | For video content, such as a movie clip or other video streams |
<source> | For media resources for media elements, defined inside video or audio elements |
<embed> | For embedded content, such as a plug-in |
<track> | For text tracks used in mediaplayers |
The Canvas Element
The canvas element uses JavaScript to make drawings on a web page.Tag | Description |
---|---|
<canvas> | For making graphics with a script |
New Form Elements
HTML5 offers more form elements, with more functionality:Tag | Description |
---|---|
<datalist> | A list of options for input values |
<keygen> | Generate keys to authenticate users |
<output> | For different types of output, such as output written by a script |
New Input Type Attribute Values
Also, the input element's type attribute has many new values, for better input control before sending it to the server:Type | Description |
---|---|
tel | The input value is of type telephone number |
search | The input field is a search field |
url | The input value is a URL |
The input value is one or more email addresses | |
datetime | The input value is a date and/or time |
date | The input value is a date |
month | The input value is a month |
week | The input value is a week |
time | The input value is of type time |
datetime-local | The input value is a local date/time |
number | The input value is a number |
range | The input value is a number in a given range |
color | The input value is a hexadecimal color, like #FF8800 |
placeholder | Specifies a short hint that describes the expected value of an input field |
HTML5 Video
HTML5 Video
Many modern websites show videos. HTML5 provides a standard for showing them.
Check if your browser supports HTML5 video
Videos on the Web
Until now, there has never been a standard for showing a video or movie on a web page.Today, most videos are shown through a plugin (like flash). However, different browsers may have different plugins.
HTML5 defines a new element which specifies a standard way to include video: the <video> element.
Video Formats
Currently, there are 3 supported video formats for the video element:Format | IE | Firefox | Opera | Chrome | Safari |
---|---|---|---|---|---|
Ogg | No | 3.5+ | 10.5+ | 5.0+ | No |
MPEG 4 | 9.0+ | No | No | 5.0+ | 3.0+ |
WebM | No | 4.0+ | 10.6+ | 6.0+ | No |
- Ogg = Ogg files with Theora video codec and Vorbis audio codec
- MPEG4 = MPEG 4 files with H.264 video codec and AAC audio codec
- WebM = WebM files with VP8 video codec and Vorbis audio codec
How It Works
To show a video in HTML5, this is all you need:Example
<video width="320" height="240" controls="controls">
<source src="movie.mp4" type="video/mp4" />
<source src="movie.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video>
<source src="movie.mp4" type="video/mp4" />
<source src="movie.ogg" type="video/ogg" />
Your browser does not support the video tag.
</video>
Try it yourself »
It is also a good idea to always include width and height attributes. If height and width are set, the space required for the video is reserved when the page is loaded. However, without these attributes, the browser does not know the size of the video, and cannot reserve the appropriate space to it. The effect will be that the page layout will change during loading (while the video load).
You should also insert text content between the <video> and </video> tags for browsers that do not support the <video> element.
The <video> element allows multiple <source> elements. <source> elements can link to different video files. The browser will use the first recognized format.
Today, Firefox, Opera, and Chrome support Ogg files. Internet Explorer, Chrome, and Safari support MPEG4 files.
To cover all the major browsers, use two <source> elements: One pointing to an MPEG4 file, and one pointing to an Ogg file.
HTML5 video Tags
Tag | Description |
---|---|
<video> | Defines a video or movie |
<source> | Defines multiple media resources for media elements, such as <video> and <audio> |
<track> | Defines text tracks in mediaplayers |
HTML5 Audio
HTML5 Audio
HTML5 provides a standard for playing audio.
Audio on the Web
Until now, there has never been a standard for playing audio on a web page.Today, most audio are played through a plugin (like flash). However, not all browsers have the same plugins.
HTML5 specifies a standard way to include audio, with the audio element.
The audio element can play sound files, or an audio stream.
Audio Formats
Currently, there are 3 main formats for the audio element:Format | IE 9 | Firefox 3.5 | Opera 10.5 | Chrome 3.0 | Safari 3.0 |
---|---|---|---|---|---|
Ogg Vorbis | No | Yes | Yes | Yes | No |
MP3 | Yes | No | No | Yes | Yes |
Wav | No | Yes | Yes | Yes | Yes |
How It Works
To play an audio file in HTML5, this is all you need: <audio src="song.ogg" controls="controls">
</audio>
</audio>
Insert content between the <audio> and </audio> tags for browsers that do not support the audio element:
Example
<audio src="song.ogg" controls="controls">
Your browser does not support the audio element.
</audio>
Your browser does not support the audio element.
</audio>
Try it yourself »
To make the audio work in Internet Explorer and Safari, add an audio file of the type MP3.
The audio element allows multiple source elements. Source elements can link to different audio files. The browser will use the first recognized format:
Example
<audio controls="controls">
<source src="song.ogg" type="audio/ogg" />
<source src="song.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>
<source src="song.ogg" type="audio/ogg" />
<source src="song.mp3" type="audio/mpeg" />
Your browser does not support the audio element.
</audio>
Try it yourself »
HTML5 audio Tags
Tag | Description |
---|---|
<audio> | Defines sound content |
<source> | Defines multiple media resources for media elements, such as <video> and <audio> |
HTML5 Canvas
HTML5 Canvas
The canvas element is used to draw graphics on a web page.
Your browser does not support the canvas element. What is Canvas?
The HTML5 canvas element uses JavaScript to draw graphics on a web page.A canvas is a rectangular area, and you control every pixel of it.
The canvas element has several methods for drawing paths, boxes, circles, characters, and adding images.
Create a Canvas Element
Add a canvas element to the HTML5 page.Specify the id, width, and height of the element:
<canvas id="myCanvas" width="200" height="100"></canvas>
Draw With JavaScript
The canvas element has no drawing abilities of its own. All drawing must be done inside a JavaScript: <script type="text/javascript">
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.fillStyle="#FF0000";
cxt.fillRect(0,0,150,75);
</script>
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
cxt.fillStyle="#FF0000";
cxt.fillRect(0,0,150,75);
</script>
Try it yourself »
var c=document.getElementById("myCanvas");
var cxt=c.getContext("2d");
The next two lines draws a red rectangle:
cxt.fillStyle="#FF0000";
cxt.fillRect(0,0,150,75);
cxt.fillRect(0,0,150,75);
Understanding Coordinates
The fillRect method above had the parameters (0,0,150,75).This means: Draw a 150x75 rectangle on the canvas, starting at the top left corner (0,0).
The canvas' X and Y coordinates are used to position drawings on the canvas.
Mouse over the rectangle below to see the coordinates:
X
Y
More Canvas Examples
Below are more examples of drawing on the canvas element:Example - Line
Draw a line by specifying where to start, and where to stop: Your browser does not support the canvas element.
Try it yourself »
Example - Circle
Draw a circle by specifying the size, color, and position: Your browser does not support the canvas element.
Try it yourself »
Example - Gradient
Draw a gradient background with the colors you specify: Your browser does not support the canvas element.
Try it yourself »
Example - Image
Put an image on the canvas:Try it yourself »
HTML5 <canvas> Tag
Tag | Description |
---|---|
<canvas> | Defines graphics |
HTML5 Web Storage
Storing Data on the Client
HTML5 offers two new objects for storing data on the client:- localStorage - stores data with no time limit
- sessionStorage - stores data for one session
In HTML5, the data is NOT passed on by every server request, but used ONLY when asked for. It is possible to store large amounts of data without affecting the website's performance.
The data is stored in different areas for different websites, and a website can only access data stored by itself.
HTML5 uses JavaScript to store and access the data.
The localStorage Object
The localStorage object stores the data with no time limit. The data will be available the next day, week, or year.How to create and access a localStorage:
Example
<script type="text/javascript">
localStorage.lastname="Smith";
document.write(localStorage.lastname);
</script>
localStorage.lastname="Smith";
document.write(localStorage.lastname);
</script>
Try it yourself »
Example
<script type="text/javascript">
if (localStorage.pagecount)
{
localStorage.pagecount=Number(localStorage.pagecount) +1;
}
else
{
localStorage.pagecount=1;
}
document.write("Visits "+ localStorage.pagecount + " time(s).");
</script>
if (localStorage.pagecount)
{
localStorage.pagecount=Number(localStorage.pagecount) +1;
}
else
{
localStorage.pagecount=1;
}
document.write("Visits "+ localStorage.pagecount + " time(s).");
</script>
The sessionStorage Object
The sessionStorage object stores the data for one session. The data is deleted when the user closes the browser window.How to create and access a sessionStorage:
Example
<script type="text/javascript">
sessionStorage.lastname="Smith";
document.write(sessionStorage.lastname);
</script>
sessionStorage.lastname="Smith";
document.write(sessionStorage.lastname);
</script>
HTML5 Input Types
HTML5 New Input Types
HTML5 has several new input types for forms. These new features allow for better input control and validation.This chapter covers the new input types:
- url
- number
- range
- Date pickers (date, month, week, time, datetime, datetime-local)
- search
- color
Browser Support
Input type | IE | Firefox | Opera | Chrome | Safari |
---|---|---|---|---|---|
No | 4.0 | 9.0 | 10.0 | No | |
url | No | 4.0 | 9.0 | 10.0 | No |
number | No | No | 9.0 | 7.0 | 5.1 |
range | No | No | 9.0 | 4.0 | 4.0 |
Date pickers | No | No | 9.0 | 10.0 | 5.1 |
search | No | 4.0 | 11.0 | 10.0 | No |
color | No | No | 11.0 | 12 | No |
Input Type - email
The email type is used for input fields that should contain an e-mail address.The value of the email field is automatically validated when the form is submitted.
Example
E-mail: <input type="email" name="user_email" />
Try it yourself »
Input Type - url
The url type is used for input fields that should contain a URL address.The value of the url field is automatically validated when the form is submitted.
Example
Homepage: <input type="url" name="user_url" />
Try it yourself »
Input Type - number
The number type is used for input fields that should contain a numeric value.You can also set restrictions on what numbers are accepted:
Example
Points: <input type="number" name="points" min="1" max="10" />
Try it yourself »
Attribute | Value | Description |
---|---|---|
max | number | Specifies the maximum value allowed |
min | number | Specifies the minimum value allowed |
step | number | Specifies legal number intervals (if step="3", legal numbers could be -3,0,3,6, etc) |
value | number | Specifies the default value |
Input Type - range
The range type is used for input fields that should contain a value from a range of numbers.The range type is displayed as a slider bar.
You can also set restrictions on what numbers are accepted:
Example
<input type="range" name="points" min="1" max="10" />
Try it yourself »
Attribute | Value | Description |
---|---|---|
max | number | Specifies the maximum value allowed |
min | number | Specifies the minimum value allowed |
step | number | Specifies legal number intervals (if step="3", legal numbers could be -3,0,3,6, etc) |
value | number | Specifies the default value |
Input Type - Date Pickers
HTML5 has several new input types for selecting date and time:- date - Selects date, month and year
- month - Selects month and year
- week - Selects week and year
- time - Selects time (hour and minute)
- datetime - Selects time, date, month and year (UTC time)
- datetime-local - Selects time, date, month and year (local time)
Example
Date: <input type="date" name="user_date" />
Try it yourself »
Input type "week": Try it yourself
Input type "time": Try it yourself
Input type "datetime": Try it yourself
Input type "datetime-local": Try it yourself
Input Type - search
The search type is used for search fields, like a site search, or Google search.The search field behaves like a regular text field.
Input Type - color
The color type is used for input fields that should contain a color.The Opera browser will allow you to select a color from a color picker, Google's Chrome will only allow hexadecimal color values to be submitted:
Example
Color: <input type="color" name="user_color" />
Try it yourself »
HTML5 <input> Tag
Tag | Description |
---|---|
<input> | Defines an input field |
HTML5 Form Elements
HTML5 New Form Elements
HTML5 has several new elements and attributes for forms.This chapter covers the new form elements:
- <datalist>
- <keygen>
- <output>
Browser Support
Tag | IE | Firefox | Opera | Chrome | Safari |
---|---|---|---|---|---|
<datalist> | No | 4.0 | 9.5 | No | No |
<keygen> | No | 4.0 | 10.5 | 3.0 | No |
<output> | No | 4.0 | 9.5 | 10.0 | 5.1 |
<datalist> Element
The <datalist> element specifies a list of options for an input field.The list is created with <option> elements inside the <datalist>.
To bind a <datalist> to an input field, let the list attribute of the input field refer to the id of the datalist:
Example
Webpage: <input type="url" list="url_list" name="link" />
<datalist id="url_list">
<option label="W3Schools" value="http://www.w3schools.com" />
<option label="Google" value="http://www.google.com" />
<option label="Microsoft" value="http://www.microsoft.com" />
</datalist>
<datalist id="url_list">
<option label="W3Schools" value="http://www.w3schools.com" />
<option label="Google" value="http://www.google.com" />
<option label="Microsoft" value="http://www.microsoft.com" />
</datalist>
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
<form action="demo_form.asp" method="get">
Username: <input type="text" name="usr_name" />
Encryption: <keygen name="security" />
<input type="submit" />
</form>
Username: <input type="text" name="usr_name" />
Encryption: <keygen name="security" />
<input type="submit" />
</form>
Try it yourself »
<output> Element
The <output> element is used for different types of output, like calculations or script output:Example
<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">0
<input type="range" name="a" value="50" />100
+<input type="number" name="b" value="50" />
=<output name="x" for="a b"></output>
</form>
<input type="range" name="a" value="50" />100
+<input type="number" name="b" value="50" />
=<output name="x" for="a b"></output>
</form>
Try it yourself »
HTML5 New Form Elements
Tag | Description |
---|---|
<datalist> | Defines a list of options for an input field |
<keygen> | Defines a key-pair generator field |
<output> | Represents the result of a calculation |
HTML5 Form Attributes
HTML5 New Form Attributes
This chapter covers some of the new attributes for <form> and <input>.New form attributes:
- 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 | 4.0 | 10.0 | 3.0 | 4.0 |
form | No | 4.0 | 9.5 | 10.0 | No |
form overrides | No | 4.0 | 10.5 | 10.0 | No |
height and width | 8.0 | 3.5 | 9.5 | 3.0 | 4.0 |
list | No | 4.0 | 9.5 | No | No |
min, max and step | No | No | 9.5 | 3.0 | No |
multiple | No | 3.5 | 11.0 | 3.0 | 4.0 |
novalidate | No | 4.0 | 11.0 | 10.0 | No |
pattern | No | 4.0 | 9.5 | 3.0 | No |
placeholder | No | 4.0 | 11.0 | 3.0 | 3.0 |
required | No | 4.0 | 9.5 | 3.0 | 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
<form action="demo_form.asp" method="get" autocomplete="on">
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br />
E-mail: <input type="email" name="email" autocomplete="off" /><br />
<input type="submit" />
</form>
First name: <input type="text" name="fname" /><br />
Last name: <input type="text" name="lname" /><br />
E-mail: <input type="email" name="email" autocomplete="off" /><br />
<input type="submit" />
</form>
Try it yourself »
autofocus Attribute
The autofocus attribute specifies that a field should automatically get focus when a page is loaded.Note: The autofocus attribute works with all <input> types.
Example
User name: <input type="text" name="user_name" autofocus="autofocus" />
Try it yourself »
form Attribute
The form attribute specifies one or more forms the input field belongs to.Note: The form attribute works with all <input> types.
The form attribute must refer to the id of the form it belongs to:
Example
<form action="demo_form.asp" method="get" id="user_form">
First name:<input type="text" name="fname" />
<input type="submit" />
</form>
Last name: <input type="text" name="lname" form="user_form" />
First name:<input type="text" name="fname" />
<input type="submit" />
</form>
Last name: <input type="text" name="lname" form="user_form" />
Try it yourself »
Form Override Attributes
The form override attributes allow you to override some of the attributes set for the form element.The form override attributes are:
- formaction - Overrides the form action attribute
- formenctype - Overrides the form enctype attribute
- formmethod - Overrides the form method attribute
- formnovalidate - Overrides the form novalidate attribute
- formtarget - Overrides the form target attribute
Example
<form action="demo_form.asp" method="get" id="user_form">
E-mail: <input type="email" name="userid" /><br />
<input type="submit" value="Submit" />
<br />
<input type="submit" formaction="demo_admin.asp" value="Submit as admin" />
<br />
<input type="submit" formnovalidate="true"
value="Submit without validation" />
<br />
</form>
E-mail: <input type="email" name="userid" /><br />
<input type="submit" value="Submit" />
<br />
<input type="submit" formaction="demo_admin.asp" value="Submit as admin" />
<br />
<input type="submit" formnovalidate="true"
value="Submit without validation" />
<br />
</form>
Try it yourself »
height and width Attributes
The height and width attributes specifies the height and width of the image used for the input type image.Note: The height and width attributes only works with <input> type: image.
Example
<input type="image" src="img_submit.gif" width="24" height="24" />
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
Webpage: <input type="url" list="url_list" name="link" />
<datalist id="url_list">
<option label="W3Schools" value="http://www.w3schools.com" />
<option label="Google" value="http://www.google.com" />
<option label="Microsoft" value="http://www.microsoft.com" />
</datalist>
<datalist id="url_list">
<option label="W3Schools" value="http://www.w3schools.com" />
<option label="Google" value="http://www.google.com" />
<option label="Microsoft" value="http://www.microsoft.com" />
</datalist>
Try it yourself »
min, max and step Attributes
The min, max and step attributes are used to specify restrictions for input types containing numbers or dates.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
Points: <input type="number" name="points" min="0" max="10" step="3" />
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
Select images: <input type="file" name="img" multiple="multiple" />
Try it yourself »
novalidate Attribute
The novalidate attribute specifies that the form or input field should not be validated when submitted.If this attribute is present the form will not validate form input.
Note: The novalidate attribute works with: <form> and the following <input> types: text, search, url, telephone, email, password, date pickers, range, and color.
Example
<form action="demo_form.asp" novalidate="novalidate">
E-mail: <input type="email" name="user_email" />
<input type="submit" />
</form>
E-mail: <input type="email" name="user_email" />
<input type="submit" />
</form>
pattern Attribute
The pattern attribute specifies a pattern used to validate an input field.The pattern is a regular expression.
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
Country code: <input type="text" name="country_code"
pattern="[A-z]{3}" title="Three letter country code" />
pattern="[A-z]{3}" title="Three letter country code" />
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
<input type="search" name="user_search" placeholder="Search W3Schools" />
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.
HTML5 Tag Reference
HTML5 Tag Reference
HTML5
HTML5 improves interoperability and reduces development costs by making precise rules on how to handle all HTML elements, and how to recover from errors.
Some of the ((new)) features in HTML5 are functions for embedding audio, video, graphics, client-side data storage, and interactive documents. HTML5 also contains ((new)) elements like <nav>, <header>, <footer>, and <figure>.
The HTML5 working group includes AOL, Apple, Google, IBM, Microsoft, Mozilla, Nokia, Opera, and many hundreds of other vendors.
Ordered Alphabetically
((new)) : ((new)) tags in HTML5.
Tag | Description |
<!--...--> | Defines a comment |
<!DOCTYPE> | Defines the document type |
<a> | Defines a hyperlink |
<abbr> | Defines an abbreviation |
<acronym> | Not supported in HTML5 |
<address> | Defines contact information for the author/owner of a document/article |
<applet> | Not supported in HTML5 |
<area> | Defines an area inside an image-map |
<article>((new)) | Defines an article |
<aside>((new)) | Defines content aside from the page content |
<audio>((new)) | Defines sound content |
<b> | Defines bold text |
<base> | Specifies the base URL/target for all relative URLs in a document |
<basefont> | Not supported in HTML5 |
<bdi>((new)) | Isolates a part of text that might be formatted in a different direction from other text outside it |
<bdo> | Overrides the current text direction |
Not supported in HTML5 | |
<blockquote> | Defines a section that is quoted from another source |
Defines the document's body | |
<br> | Defines a single line break |
<button> | Defines a clickable button |
<canvas>((new)) | Used to draw graphics, on the fly, via scripting (usually JavaScript) |
<caption> | Defines a table caption |
<center> | Not supported in HTML5 |
<cite> | Defines the title of a work |
<code> | Defines a piece of computer code |
Specifies column properties for each column within a <colgroup> element | |
Specifies a group of one or more columns in a table for formatting | |
<command>((new)) | Defines a command button that a user can invoke |
<datalist>((new)) | Defines a list of options for an input field |
Defines a description of a term in a definition list | |
Defines deleted text | |
<details>((new)) | Defines details of an element |
Defines a definition term | |
Not supported in HTML5 | |
Defines a section in a document | |
Defines a definition list | |
Defines a term (an item) in a definition list | |
Defines emphasized text | |
<embed>((new)) | Defines external interactive content or plugin |
Defines a border around elements in a form | |
<figcaption>((new)) | Defines the caption of a figure element |
<figure>((new)) | Defines a group of media content, and their caption |
Not supported in HTML5 | |
<footer>((new)) | Defines a footer for a section or page |
Defines an HTML form for user input | |
Not supported in HTML5 | |
Not supported in HTML5 | |
Defines HTML headings | |
Defines information about the document | |
<header>((new)) | Defines a header for a section or page |
<hgroup>((new)) | Defines information about a section in a document |
Defines a horizontal line | |
Defines an HTML document | |
Defines italic text | |
Defines an inline frame | |
Defines an image | |
Defines an input control | |
Defines inserted text | |
<keygen>((new)) | Defines a key-pair generator field (for forms) |
Defines keyboard input | |
Defines a label for an input element | |
Defines a caption for a <fieldset>, <figure>, or <details> element | |
Defines a list item | |
Defines the relationship between a document and an external resource (most used to link to style sheets) | |
Defines a client-side image-map | |
<mark>((new)) | Defines marked text |
Defines a list/menu of commands | |
Defines metadata about an HTML document | |
<meter>((new)) | Defines a scalar measurement within a known range (a gauge) |
<nav>((new)) | Defines navigation links |
Not supported in HTML5 | |
Defines an alternate content for users that do not support client-side scripts | |
Defines an embedded object | |
Defines an ordered list | |
Defines a group of related options in a drop-down list | |
Defines an option in a drop-down list | |
<output>((new)) | Defines the result of a calculation |
Defines a paragraph | |
Defines a parameter for an object | |
Defines preformatted text | |
<progress>((new)) | Represents the progress of a task |
Defines a short quotation | |
<rp>((new)) | Defines what to show in browsers that not support ruby annotations |
<rt>((new)) | Defines an explanation/pronunciation of characters (for East Asian typography) |
<ruby>((new)) | Defines a ruby annotation (for East Asian typography) |
Defines text that is no longer correct | |
Defines sample output from a computer program | |
Defines a client-side script | |
<section>((new)) | Defines a section in a document |
Defines a drop-down list | |
Defines smaller text | |
<source>((new)) | Defines multiple media resources for media elements (<video> and <audio>) |
Defines a section in a document | |
Not supported in HTML5 | |
Defines important text | |
Defines style information for a document | |
Defines subscripted text | |
<summary>((new)) | Defines the header of a <detail> element |
Defines superscripted text | |
Defines a table | |
Groups the body content in a table | |
Defines a cell in a table | |
Defines a multiline input control (text area) | |
Groups the footer content in a table | |
Defines a header cell in a table | |
Groups the header content in a table | |
<time>((new)) | Defines a date/time |
Defines a title for the document | |
Defines a row in a table | |
<track>((new)) | Defines text tracks for media elements (<video> and <audio>) |
<tt> | Not supported in HTML5 |
<u> | Not supported in HTML5 |
<ul> | Defines an unordered list |
<var> | Defines a variable |
<video>((new)) | Defines a video or movie |
<wbr>((new)) | Defines a possible line-break |
<xmp> | Not supported in HTML5 |
Subscribe to:
Posts (Atom)