


What are the tags and common rules in HTML5? Introduction to html5 tags and rules
This article introduces to you what are the tags and common rules in HTML5? The introduction of html5 tags and rules has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.
1. Naming rules
[Mandatory]class: The word must be all lowercase, separated by -, and must represent the content or function of the corresponding module or component. It must not be named with the built-in HTML style , naming should have clear semantics.
[Mandatory]id: must remain unique in the page, and the naming should have clear semantics.
2. Tag
[Mandatory]The tag name in Html must use lowercase letters.
[Mandatory] The closing of the tag must comply with the regulations of HTML5.
[Mandatory] The use of tags must comply with the nesting rules of tags. For example: p must not be placed in p, and tbody must be placed in table.
[Recommendation] The use of tags must follow the semantics of the tags, for example:
p - paragraph
h1, h2, h3, h4, h5, h6 - hierarchical title
strong,em - emphasis
ins - insertion of
del - deletion of
abbr - abbreviation
code - code identification
cite - title of the work from which the citation is derived
q - quotation
blockquote - a paragraph or long quotation
ul - Unordered list
ol - Ordered list
dl,dt,dd - Defined list
[Recommendation] Tables should not be used for layout when CSS can achieve the same requirement.
3. Attributes
[Mandatory] Attributes must use lowercase letters, and their attribute values must be surrounded by double quotes.
[Suggestion] Boolean type suggestions do not add attribute values. It is recommended that custom attributes be prefixed with xxx-, and data-
4 is recommended. DOCTYPE
[Mandatory] Use doctype to enable standard mode. It is recommended to use uppercase DOCTYPE
5. Language Encoding
[Recommended] Helps improve the accessibility of the page. The correct lang attribute must be set, for example:
[Mandatory] The page must specify the character encoding meta, and must be the first direct child element of head, for example:
6. CSS and JavaScript introduction
[Mandatory] When introducing css, you must specify rel="stylesheet", and when introducing css and javascript, you must specify the type attribute.
[Recommendation]Javascript code must be placed at the end of the page or loaded asynchronously.
7. Head content
[Mandatory] The Title tag must be set as a direct child element of the head and immediately after the charset statement.
[Mandatory] Favicon is guaranteed to be accessible, for example:
[Mandatory] The Viewport attribute must be specified.
8. Pictures
[Mandatory] It is prohibited for the src value of img to be empty, and the default src attribute value must also be added to delayed-loaded pictures.
[Recommendation] Add alt attribute value to important images.
[Recommendation]Add width and height attributes to avoid page jitter.
9. Control title
[Mandatory] A control with a text title must use a label to associate it with its title, for example:
<label><input type="checkbox"name="confirm" value="on"> 我已确认上述条款</label>或<labelfor="user">用户:</label><inputtype="text" name="user" id="user">
10. Button
[ Mandatory] The type attribute value must be specified when using the button element
11. Accessibility
[Recommendation] When using JavaScript for form submission, the native submission function should be allowed to work properly.
[Recommendation] Specify the type attribute of the input box according to the content type, for example:
12. Multimedia
[Recommendation] Use audio and video tags to play When using audio and video, you should pay attention to the format:
Audio format: MP3, WAV, Ogg
Video format: MP4, WebM, Ogg
13. Note
[Mandatory]For The CSS and JavaScript code of the page or module must be commented in detail
Related recommendations:
Summary of changes in the page structure of html5 and adding and deleting tags
Example code of div tag in HTML5
The above is the detailed content of What are the tags and common rules in HTML5? Introduction to html5 tags and rules. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



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.

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.

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.

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.

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.

Yes, H5 page production is an important implementation method for front-end development, involving core technologies such as HTML, CSS and JavaScript. Developers build dynamic and powerful H5 pages by cleverly combining these technologies, such as using the <canvas> tag to draw graphics or using JavaScript to control interaction behavior.

The article discusses managing user location privacy and permissions using the Geolocation API, emphasizing best practices for requesting permissions, ensuring data security, and complying with privacy laws.

H5. The main difference between mini programs and APP is: technical architecture: H5 is based on web technology, and mini programs and APP are independent applications. Experience and functions: H5 is light and easy to use, with limited functions; mini programs are lightweight and have good interactiveness; APPs are powerful and have smooth experience. Compatibility: H5 is cross-platform compatible, applets and APPs are restricted by the platform. Development cost: H5 has low development cost, medium mini programs, and highest APP. Applicable scenarios: H5 is suitable for information display, applets are suitable for lightweight applications, and APPs are suitable for complex functions.
