Home Web Front-end H5 Tutorial HTML5 HTML element extension (Part 1) - Overview of newly added elements and usage_html5 tutorial skills

HTML5 HTML element extension (Part 1) - Overview of newly added elements and usage_html5 tutorial skills

May 16, 2016 pm 03:49 PM

Consider our process of developing a page :
1. Design the structure of the page - HTML: This process is to build the structure of the web page using various HTML elements.
2. Design the appearance of the page - CSS: This process is to use CSS to improve the appearance of the web page.
3. Design the behavior of the page - Javascript: This process is to assign certain behaviors to the elements of the web page.
In addition to CSS, HTML5 has been expanded to varying degrees in the other two aspects. This series is focused on the first aspect. Previously, we have learned about the complex canvas and svg elements. The following chapters will summarize other elements added by HTML5.

Structural elements
HTML5 adds new structural elements, such as header, footer, navigation nav, content article, section, etc. The meaning is as shown below:

In addition to this structural element of the entire page, HTML5 also adds block-level semantic elements, such as the auxiliary element aside, the image element figure, the detailed description element details, etc. In addition to better displaying the layout meaning of the page, these elements are no different from ordinary divs. You still need to rely on CSS to display these elements. Here is a simple example:

Copy the code
The code is as follows:

< ;html>

Dxy Blog



< ;h1>dxy1982 Blog








Copyright 2012 dxy1982






Although These elements are relatively simple to use, but there are still a few points to note :
1. Do not use section as a substitute for div
Section is not a style container. The section element represents a semantic part of the content that helps build a document summary. It should contain a header. It usually exists as part of article (of course article can also be a part of it). If you're looking for an element to use as a page container or need additional style containers, stick with divs.
2. Only use header and hgroup when needed
It is meaningless to write tags that do not need to be written. The usage scenarios of header and hgroup are usually as follows:
• The header element represents a set of introductory or navigational auxiliary text, which is often used as the head of a section.
• When the header has multiple layers of structure, such as sub-headers, subtitles, various logos, etc., use hgroup to combine h1-h6 elements as the header of the section.
If there are only a few header elements in the header or hgroup here, why not remove these two useless tags, for example:

Copy code
The code is as follows:


 

 

My best blog post


 

-->


Modify directly to:

Copy code
The code is as follows:


 

My best blog post


 


The same thing:

Copy code
Code As follows:


 

 

My best blog post


 

p>by Rich Clark




Change directly to:

Copy code
The code is as follows:


My best blog post


by Rich Clark< ;/p>



3. Do not abuse the nav
nav element to represent blocks in the page that link to other pages or other parts of this page; include navigation links block.
But not all links on the page need to be placed in the nav element - this element is intended to be used as the main navigation block. To give a specific example, there are often many links in the footer, such as terms of service, home page, copyright statement page, etc. The footer element itself is sufficient to handle these situations. Although the nav element can also be used here, we usually think it is unnecessary.
4. Don’t abuse figure
Figure should be “some flowing content, sometimes with its own title description. It is generally referenced as an independent unit in the document flow.” This is the most important thing about figure. Best applicable scenario - it can be moved from the main content page to the sidebar without affecting the document flow. Figures should only be referenced within the document, or surrounded by section elements.
If the figure is purely for presentation (such as a logo), it is not referenced elsewhere in the document, and there is no need to move the position, then absolutely do not use figure.
5. Do not use unnecessary type attributes
In HTML5, script and style elements no longer require type attributes. Of course, there is nothing wrong with writing it, but from a best practice perspective, there is no need to write it.

Audio element
The audio element is used to identify sound content, such as music or any other audio stream. The formats supported by this element are shown in the following table:
  IE 9 Firefox 3.5 Opera 10.5 Chrome 3.0 Safari 3.0
Ogg Vorbis    
MP3    
Wav    
The

audio tag has some attributes used to control the content, when and how to play the audio. These attributes are: src (file name), preload (loaded when the page is loaded), controls (display control) , loop (loop) and autoplay (automatic play). In the example below, the audio will play as soon as the page loads. It will continue to play, and the controls provided will allow the user to stop or restart the audio:

Copy code
The code is as follows:



If the browser does not support the element, the text information of the element is displayed.
If the autoplay element is set, the preload attribute is automatically ignored. If preload="auto" is set, the audio will be loaded after the page is loaded. The
audio element allows specifying multiple source elements to be compatible with browser issues. The source element can link different audio files. The browser will use the first recognized format:

Copy the code
The code is as follows:



Video Element The video element allows you to play video clips or stream visual media. The formats supported by this element are shown in the following table:

It has all the attributes of the audio element, plus: muted (mute), poster (waiting for pictures), width and height. Needless to say the last two meanings. The poster attribute (specifying an absolute or relative URL) allows you to find an image to use when the video is loading or when the video is not loading at all; muted means mute.

Video also supports using source elements to solve compatibility issues. Look at a small example:

Copy the code
The code is as follows:



If you want not to play the sound of the video, just set muted="muted".
In addition, the video element also provides some methods, properties and events to support controlling the playback process during DOM operations. For example, call the play, pause, load and other methods of the element. There are also attributes such as volume and playback time that can be read or set directly. In addition, there are start play, pause, end events, etc. that can be used. Look at the example below:

Copy the code
The code is as follows:








< button onclick="makeNormal()">Normal








actually needed here Pay attention to a new way of writing: In the above example, we write the audio element like this:

Copy the code
The code is as follows :



In fact, many Boolean attributes such as controls, autoplay, and loop have been introduced in HTML5. You can write these attributes like the above, but The recommended writing method is as follows:

Copy the code
The code is as follows:

< ;audio src="MyFirstMusic.ogg" controls autoplay loop>
Your browser does not support the audio element.


Because when the browser encounters these attributes, it means that these attributes are turned on. In other words, if you write these attributes and forcibly set them to false, the effect will still be the same. is true, so it is generally recommended to only write the attribute name.
This writing problem also exists in forms. Many new attributes of form and input are Boolean attributes, and the recommended writing method should be used.

Elements indicating measurements
Not every browser supports the following elements, but basically the effect can be seen on Chrome.
Progress bar element
Use this element to display the download progress bar. It has only two attributes: value and max. It is very simple. Both Chrome and FireFox support it.

Copy code
The code is as follows:

Download progress:
33%



Measure element
Use this element to display an indication icon of a given value in the standard range class. Values ​​in different ranges will display different colors. Some websites use this tool to display the user's current experience value. When the browser does not support this element, the text in the middle of the element will be displayed directly. Currently Chrome already supports it.

Copy code
The code is as follows:

Your score is:
B .
< /p>


Run it and you will see a yellow scroll bar-like thing; if you change the value to 50, you will find that the color of the indicator bar is programmed red.

That’s it for the introduction of the newly added elements. For more element descriptions, please see the complete Tag list in W3C.

Practical reference:
W3C tutorial: http://www.w3schools.com/html5/default.asp
HTML5 Official guidance: http://dev.w3.org/html5/html-author/
A pretty good guidance website: http://html5doctor.com/
HTML5 Chinese tutorial: http://www.html5china.com/
A good front-end blog: http://www.pjhome.net/default.asp?cateID= 1

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 AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

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)

What exactly does H5 page production mean? What exactly does H5 page production mean? Apr 06, 2025 am 07:18 AM

H5 page production refers to the creation of cross-platform compatible web pages using technologies such as HTML5, CSS3 and JavaScript. Its core lies in the browser's parsing code, rendering structure, style and interactive functions. Common technologies include animation effects, responsive design, and data interaction. To avoid errors, developers should be debugged; performance optimization and best practices include image format optimization, request reduction and code specifications, etc. to improve loading speed and code quality.

How to run the h5 project How to run the h5 project Apr 06, 2025 pm 12:21 PM

Running the H5 project requires the following steps: installing necessary tools such as web server, Node.js, development tools, etc. Build a development environment, create project folders, initialize projects, and write code. Start the development server and run the command using the command line. Preview the project in your browser and enter the development server URL. Publish projects, optimize code, deploy projects, and set up web server configuration.

How to make h5 click icon How to make h5 click icon Apr 06, 2025 pm 12:15 PM

The steps to create an H5 click icon include: preparing a square source image in the image editing software. Add interactivity in the H5 editor and set the click event. Create a hotspot that covers the entire icon. Set the action of click events, such as jumping to the page or triggering animation. Export H5 documents as HTML, CSS, and JavaScript files. Deploy the exported files to a website or other platform.

What is the H5 programming language? What is the H5 programming language? Apr 03, 2025 am 12:16 AM

H5 is not a standalone programming language, but a collection of HTML5, CSS3 and JavaScript for building modern web applications. 1. HTML5 defines the web page structure and content, and provides new tags and APIs. 2. CSS3 controls style and layout, and introduces new features such as animation. 3. JavaScript implements dynamic interaction and enhances functions through DOM operations and asynchronous requests.

How to make pop-up windows with h5 How to make pop-up windows with h5 Apr 06, 2025 pm 12:12 PM

H5 pop-up window creation steps: 1. Determine the triggering method (click, time, exit, scroll); 2. Design content (title, text, action button); 3. Set style (size, color, font, background); 4. Implement code (HTML, CSS, JavaScript); 5. Test and deployment.

What application scenarios are suitable for H5 page production What application scenarios are suitable for H5 page production Apr 05, 2025 pm 11:36 PM

H5 (HTML5) is suitable for lightweight applications, such as marketing campaign pages, product display pages and corporate promotion micro-websites. Its advantages lie in cross-platformity and rich interactivity, but its limitations lie in complex interactions and animations, local resource access and offline capabilities.

Is h5 same as HTML5? Is h5 same as HTML5? Apr 08, 2025 am 12:16 AM

"h5" and "HTML5" are the same in most cases, but they may have different meanings in certain specific scenarios. 1. "HTML5" is a W3C-defined standard that contains new tags and APIs. 2. "h5" is usually the abbreviation of HTML5, but in mobile development, it may refer to a framework based on HTML5. Understanding these differences helps to use these terms accurately in your project.

What Does H5 Refer To? Exploring the Context What Does H5 Refer To? Exploring the Context Apr 12, 2025 am 12:03 AM

H5referstoHTML5,apivotaltechnologyinwebdevelopment.1)HTML5introducesnewelementsandAPIsforrich,dynamicwebapplications.2)Itsupportsmultimediawithoutplugins,enhancinguserexperienceacrossdevices.3)SemanticelementsimprovecontentstructureandSEO.4)H5'srespo

See all articles