HTML5 28 new features you need to know

Source: Internet
Author: User
Tags button type

1. The new DOCTYPE
Although using <! DOCTYPE Html&gt, even if the browser does not understand the phrase will be in accordance with the standard mode to render
2. Figure elements
Use <figure> and <figcaption> to semantically represent a picture with a title
<figure>

<figcaption>
<p>this is an image of something interesting. </p>
</figcaption>
</figure>
3. Redefined <small>
<small> has been redefined and is now used to represent small typography, such as the copyright notice at the bottom of the site
4. Remove the type attribute from the link and script tags
5. Add/No parentheses
HTML5 There are no strict requirements attributes must be quoted, closed and not closed, but it is recommended to enclose quotes and closed labels
6. To make your content editable, just add a contenteditable property
7. Email Inputs
If we set the type of input to e-mail, the browser verifies that the input is an email type, not just the front-end checksum, and the backend has to have a corresponding checksum.
8. Placeholders
The meaning of this input property is that you don't have to do placeholder with JavaScript.
9. Local Storage
Using the local storage can permanently store large pieces of data on the client side (unless actively deleted), most browsers now support, before use can detect whether Window.localstorage exists
10. Semantic Headers and Footer
11. More HTML5 Form Features
IE and HTML5
By default, HTML5 new elements are rendered inline, but you can use the following method to make
It is rendered in block mode
Header, footer, article, section, Nav, menu, Hgroup {
Display:block;
}
Unfortunately, IE ignores these styles and can fix them like this:
Document.createelement ("article");
Document.createelement ("footer");
Document.createelement ("header");
Document.createelement ("Hgroup");
Document.createelement ("Nav");
Document.createelement ("menu");
Hgroup.
Typically used in the header to group a set of headings together, such as
. Required Properties
The Required property defines whether an input is required, and you can declare it as follows
<input type= "text" name= "Someinput" required>
Or
<input type= "text" name= "Someinput" required= "required" >
The . Autofocus Property
As its meaning is, it's focused on the input box.
<input type= "text" name= "Someinput" placeholder= "Douglas Quaid" required autofocus>
. Audio Support
HTML5 provides <audio> tags, you do not need to follow third-party plug-ins to render audio, most modern browsers provide support for HTML5 audio, but there is still a need to provide some compatibility processing, such as
<audio autoplay= "AutoPlay" controls= "Controls" >
<source src= "File.ogg"/><!–ff–>
<source src= "file.mp3″/><!–webkit–>
<a href= "File.mp3″>download this file.</a>
</audio>
. Video Support
And audio very much like the,<video> tag provides support for video, since the HTML5 document does not specify a specific encoding for video, the browser decides which encodings to support, resulting in a lot of inconsistencies. Safari and IE support the encoded format of H. Theora and Vorbis encoded format, Firefox and Opera, when using HTML5 video, you must provide:
<video Controls Preload>
<source src= "COHAGENPHONECALL.OGV" type= "VIDEO/OGG; Codecs= ' Vorbis, Theora ' "/>
<source src= "cohagenphonecall.mp4″type=" VIDEO/MP4; ' codecs= ' avc1.42e01e, mp4a.40.2′ '/>
<p> Your browser is old. <a href= "Cohagenphonecall.mp4″>download this video instead.</a> </p>
</video>
18. Pre-load Video
The Preload property is as simple as its literal meaning, and you need to decide whether you need to preload the video when the page loads
<video preload>
19. Display Video Control
<video preload controls>
20. Regular Expressions
Because of the pattern attribute, we can use regular expressions directly in your markup.
<form action= "" method= "POST" >
<label for= "username" >create a username: </label>
<input type= "text" name= "username" id= "username" placeholder= "4 <> 10″pattern=" [a-za-z]{4,10} "autofocus Required>
<button type= "Submit" >go </button>
</form>
21. Detection attribute Support
In addition to Modernizr, we can easily detect whether some properties are supported by JavaScript, such as:
<script>
if (! ') Pattern ' in document.createelement (' input ')) {
Do Client/server side validation
}
</script>
Mark Element
Think of the <mark> element as a highlight, and when I select a piece of text, the markup effect of JavaScript on HTML should look like this:
<p> They were interrupted, just after Quato said, <mark> "Open Your Mind" &LT;/MARK&GT;. </p>
23. When to use <div>
HTML5 has introduced so many elements, so div do we still need to use it? div You can use when there are no better elements.
24. Want to use HTML5 now?
Don't wait 2022, you can use it now, just do it.
25. Which is not HTML5
1) SVG
2) CSS3
3) geolocation
4) Client Storage
5) Web Sockets
The . Data property
<div id= "mydiv" data-custom-attr= "My Value" > Bla bla </div>
Used in CSS:
<style>
H1:hover:after {
Content:attr (Data-hover-response);
Color:black;
Position:absolute;
left:0;
}
</style>
&LT;H1 data-hover-response= "I said Don ' t Touch me!" > Don ' t Touch Me . Output element
The <output> element is used to display the result of the calculation, and there is a for property that is the same as the label
28. Create a slider with range input
The range type referenced by HTML5 can create a slider that accepts Min, Max, step, and Value properties
You can use CSS: Before and: After to display the values of min and Max
<input type= "range" name= "range" min= "0″max=" 10″step= "1″value=" ">
Input[type=range]:before {content:attr (min); padding-right:5px;
}
Input[type=range]:after {content:attr (max); padding-left:5px;}

Original address: http://www.jb51.net/html5/45220.html

HTML5 28 new features you need to know

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.