28 new features of HTML5 language learning

Source: Internet
Author: User

1. The new DOCTYPE

Although using <! DOCTYPE Html>, 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

    1. <figure>
    2. src= "Path/to/image" alt= "about
      Image " />
    3. <figcaption>
    4. <p> This is an image of something interesting. </p>
    5. </figcaption>
    6. </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

    1. Header, footer, article, section, Nav, menu, Hgroup {
    2. Display:block;
    3. }

Unfortunately, IE ignores these styles and can fix them like this:

    1. Document.createelement ("article");
    2. Document.createelement ("footer");
    3. Document.createelement ("header");
    4. Document.createelement ("Hgroup");
    5. Document.createelement ("Nav");
    6. Document.createelement ("menu");

Hgroup.

Typically used in the header to group a set of headings together, such as

    1. Recall Fan Page
    2. People who want the memory of a lifetime.

. Required Properties

The Required property defines whether an input is required, and you can declare it as follows

    1. <input type= "text" name= "Someinput" required>
    2. <!--or-
    3. <input type= "text" name= "Someinput" required= "required">

The. Autofocus Property

As its meaning is, it's focused on the input box.

    1. <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

    1. <audio autoplay= "AutoPlay" controls= "Controls">
    2. <source src= "File.ogg" /><!–ff–>
    3. <source src= "File.mp3″ /><!–webkit–>
    4. <a href= "File.mp3″>Download this file. </a>
    5. </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:

    1. <video controls preload>
    2. <source src= "COHAGENPHONECALL.OGV" type= "VIDEO/OGG; Codecs= ' Vorbis,
      Theora ' " />
    3. <source src= "cohagenphonecall.mp4″type=" VIDEO/MP4;
      ' codecs= ' avc1.42e01e, mp4a.40.2′ ' />
    4. <p> Your browser is old. <a href= "Cohagenphonecall.mp4″>Download this video instead. </a> </p>
    5. </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

    1. <video preload>

19. Display Video Control

    1. <video preload controls>

20. Regular Expressions

Because of the pattern attribute, we can use regular expressions directly in your markup.

    1. <form action= "" method= "POST">
    2. <label for= "username">Create a username: </label>
    3. <input type= "text" name= "username" id= "username" placeholder= "4 <> 10″pattern=" [ a-za-z]{4,10} "autofocus required>
    4. <button type= "Submit">Go </button>
    5. </form>

21. Detection attribute Support

In addition to Modernizr, we can easily detect whether some properties are supported by JavaScript, such as:

    1. <script>
    2. if (!’ Pattern ' in document.createelement (' input ')) {
    3. Do Client/server side validation
    4. }
    5. </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:

    1. Search Results
    2. <p> They were interrupted, just after Quato said, <mark>' Open your mind '</mark>. </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

    1. <div id= "mydiv" data-custom-attr= "My Value"> bla bla </div>

Used in CSS:

    1. <style>
    2. H1:hover:after {
    3. Content:attr (Data-hover-response);
    4. Color:black;
    5. Position:absolute;
    6. left:0;
    7. }
    8. </style>
    9. 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 sliders that accept min, Max, step, and Value properties using CSS: Before and: After to display the values of min and Max

    1. <input type= "range" name= "range" min= "0″max=" 10″step= "1″value=" ">
    2. <style>
    3. Input[type=range]:before {content:
      attr (min); padding-right:5px;
    4. }
    5. Input[type=range]:after {content:
      attr (max); padding-left:5px;}
    6. </style>

Copyright notice: I feel like I'm doing a good job. I hope you can move your mouse and keyboard for me to order a praise or give me a comment, under the Grateful!_____________________________________________________ __ Welcome reprint, in the hope that you reprint at the same time, add the original address, thank you with

28 new features of HTML5 language learning

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.