Home Web Front-end H5 Tutorial Detailed introduction of 28 new features of h5

Detailed introduction of 28 new features of h5

May 12, 2017 pm 12:02 PM

1. New Doctype

Even if you use <!DOCTYPE html>, even if the browser does not understand this sentence, it will render it in standard mode

You can also consider using the weird box pattern

2. Figure element
Use <figure> and <figcaption> to semantically represent Picture with title

&lt;figure&gt; 
&lt;img src=”path/to/image” alt=”About image” /&gt; 
&lt;figcaption&gt; 
&lt;p&gt;This is an image of something interesting. &lt;/p&gt; 
&lt;/figcaption&gt; 
&lt;/figure&gt;
Copy after login

3. Redefined <small>
<small> has been redefined and is now used to mean Small typesetting, such as the copyright statement at the bottom of the website
4. Remove the type attribute in the link and script tags
5. Add/without brackets

HTML5 does not have strict requirements for attributes Add quotes, close or not, but it is recommended to add quotes and closing tags
6. To make your content editable, just add a contenteditable attribute
7. Email Inputs

If When we set the input type to email, the browser will verify whether the input is of email type. Of course, we cannot just rely on the front-end verification, the back-end must also have corresponding verification
8. Placeholders
The meaning of this input attribute is that there is no need to use javascript to achieve the placeholder effect
9. Local Storage
Using Local Storage can permanently store large data fragments on the client (unless Active deletion), currently supported by most browsers, you can check whether window.localStorage exists before using it
10. Semantic header and footer
11. More HTML5 form features
12. IE and HTML5

By default, HTML5 new elements are rendered inline, but you can use the following method to
render them in block

header, footer, article, section, nav, menu, hgroup { 
display: block; 
}
Copy after login

Unfortunately IE will ignore these styles. You can fix them as follows:

document.createElement(”article”); 
document.createElement(”footer”); 
document.createElement(”header”); 
document.createElement(”hgroup”); 
document.createElement(”nav”); 
document.createElement(”menu”);
Copy after login

13. hgroup
is generally used in the header to group a group of titles together, such as

&lt;header&gt; 
&lt;hgroup&gt; 
&lt;h1&gt; Recall Fan Page &lt;/h1&gt; 
&lt;h2&gt; Only for people who want the memory of a lifetime. &lt;/h2&gt; 
&lt;/hgroup&gt; 
&lt;/header&gt;
Copy after login

14. Required attribute
The required attribute defines whether an input is required. You can declare

&lt;input type=”text” name=”someInput” required&gt;
Copy after login

or

&lt;input type=”text” name=”someInput” required=”required”&gt;
Copy after login

# as follows ##15. Autofocus attribute Just like its meaning, it is to focus on the input box

&lt;input type=”text” name=”someInput” placeholder=”Douglas Quaid” required autofocus&gt;
Copy after login

16. Audio support HTML5 provides <audio> tag, you no longer need to follow third-party plug-ins to render
audio. Most modern browsers provide support for HTML5 Audio, but currently you still need to provide some compatibility processing, such as

&lt;audio autoplay=”autoplay” controls=”controls”&gt; 
&lt;source src=”file.ogg” /&gt;&lt;!–FF–&gt; 
&lt;source src=”file.mp3″ /&gt;&lt;!–Webkit–&gt; 
&lt;a href=”file.mp3″&gt;Download this file.&lt;/a&gt; 
&lt;/audio&gt;
Copy after login

17. Video support Much like Audio, the <video> tag provides support for video. Since the HTML5 document does not specify a specific encoding for video, the browser decides to support it. Which encoding caused a lot of inconsistencies. Safari and IE support H.264 encoding format, Firefox and Opera support Theora and Vorbis encoding format. When using HTML5 video, you must provide both:

&lt;video controls preload&gt; 
&lt;source src=”cohagenPhoneCall.ogv” type=”video/ogg; codecs=’vorbis, theora’” /&gt; 
&lt;source src=”cohagenPhoneCall.mp4″ type=”video/mp4; ’codecs=’avc1.42E01E, mp4a.40.2′” /&gt; 
&lt;p&gt; Your browser is old. &lt;a href=”cohagenPhoneCall.mp4″&gt;Download this video instead.&lt;/a&gt; &lt;/p&gt; 
&lt;/video&gt;
Copy after login

18. PreloadingVIDEO The preload attribute is as simple as its literal meaning. You need to decide whether you need to preload the video when the page loads

&lt;video preload&gt;
Copy after login

19. Display video Control

&lt;video preload controls&gt;
Copy after login

20. Regular Expression Due to the pattern attribute, we can use regular expressions directly in your markup

&lt;form action=”&quot; method=”post”&gt; 
&lt;label for=”username”&gt;Create a Username: &lt;/label&gt; 
&lt;input type=”text” name=”username” id=”username” placeholder=”4 &lt;&gt; 10″ pattern=”[A-Za-z]{4,10}” autofocus required&gt; 
&lt;button type=”submit”&gt;Go &lt;/button&gt; 
&lt;/form&gt;
Copy after login

21. Detecting attribute support In addition to Modernizr, we can also simply detect whether some attributes are supported through javascript, such as:

&lt;script&gt; 
if (!’pattern’ in document.createElement(’input’) ) { 
// do client/server side validation 
} 
&lt;/script&gt;
Copy after login

22. Mark element Think of the <mark> element as a highlight. When I select a piece of text, the markup effect of javascript on HTML should be like this:

&lt;h3&gt; Search Results &lt;/h3&gt; 
&lt;p&gt; They were interrupted, just after Quato said, &lt;mark&gt;”Open your Mind”&lt;/mark&gt;. &lt;/p&gt;
Copy after login

23. When to use <p> HTML5 has introduced so many elements, so do we still need to use p? You can use p when there is no better element.

24. Want to use HTML5 immediately? Don’t wait for 2022, you can use it now, just do it.

25. What is not HTML5 1)SVG
2)CSS3
3)Geolocation
4)Client Storage
5)Web Sockets

26. Data attribute

&lt;p id=”myp” data-custom-attr=”My Value”&gt; Bla Bla &lt;/p&gt;
Copy after login

Used in CSS:

&lt;style&gt; 
h1:hover:after { 
content: attr(data-hover-response); 
color: black; 
position: absolute; 
left: 0; 
} 
&lt;/style&gt; 
&lt;h1 data-hover-response=”I Said Don’t Touch Me!”&gt; Don’t Touch Me &lt;/h1&gt;
Copy after login

27. Output元素
<output>元素用来显示计算结果,也有一个和label一样的for属性
28. 用Range Input来创建滑块
HTML5引用的range类型可以创建滑块,它接受min, max, step和value属性
可以使用css的:before和:after来显示min和max的值

&lt;input type=”range” name=”range” min=”0″ max=”10″ step=”1″ value=”&quot;&gt; 
input[type=range]:before { content: attr(min); padding-right: 5px; 
} 
input[type=range]:after { content: attr(max); padding-left: 5px;}
Copy after login

【相关推荐】

1. 免费h5在线视频教程

2. HTML5 完整版手册

3. php.cn原创html5视频教程

The above is the detailed content of Detailed introduction of 28 new features of h5. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed introduction to what wapi is Detailed introduction to what wapi is Jan 07, 2024 pm 09:14 PM

Detailed introduction to what wapi is

Detailed explanation of whether win11 can run PUBG game Detailed explanation of whether win11 can run PUBG game Jan 06, 2024 pm 07:17 PM

Detailed explanation of whether win11 can run PUBG game

Introducing the latest Win 11 sound tuning method Introducing the latest Win 11 sound tuning method Jan 08, 2024 pm 06:41 PM

Introducing the latest Win 11 sound tuning method

Introduction to the skills and attributes of Hua Yishan Heart of the Moon Lu Shu Introduction to the skills and attributes of Hua Yishan Heart of the Moon Lu Shu Mar 23, 2024 pm 05:30 PM

Introduction to the skills and attributes of Hua Yishan Heart of the Moon Lu Shu

PyCharm Beginner's Guide: Comprehensive Analysis of Replacement Functions PyCharm Beginner's Guide: Comprehensive Analysis of Replacement Functions Feb 25, 2024 am 11:15 AM

PyCharm Beginner's Guide: Comprehensive Analysis of Replacement Functions

Detailed introduction of Samsung S24ai functions Detailed introduction of Samsung S24ai functions Jun 24, 2024 am 11:18 AM

Detailed introduction of Samsung S24ai functions

Detailed information on the location of the printer driver on your computer Detailed information on the location of the printer driver on your computer Jan 08, 2024 pm 03:29 PM

Detailed information on the location of the printer driver on your computer

What is Dogecoin What is Dogecoin Apr 01, 2024 pm 04:46 PM

What is Dogecoin

See all articles