One of the major changes in HTML5 is: Separating the semantics of an element from the impact of the element on the rendering results of its content. In principle, this makes sense. HTML elements are responsible for the structure and meaning of the document content, and the presentation of the content is controlled by CSS styles applied to the elements. The following introduces the most basic HTML elements: document elements and metadata elements.
1. Build the basic document structure
There are only 4 document elements: DOCTYPE element, html element, head element, and body element.
1. DOCTYPE element
Every HTML document must start with a DOCTYPE element. It tells the browser two things: first, that it is dealing with an HTML document; and second, the version of HTML used to mark up the document's content.
Note, the DTD required in HTML4 is no longer used in HTML5!
If the web page code contains the DOCTYPE element, the browser will parse it according to the standards you declare;
If you do not add the DOCTYPE element, the browser will Put the web page into quirks mode, there will be a certain difference between the two! !
<!-- HTML4 --><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <!-- HTML5 --><!DOCTYPE HTML>
2. Other elements
<!DOCTYPE HTML><html> <head> <title>title</title> </head> <body> 文档内容 </body></html>
It should be noted that there must be a title element in the head element!
2. Use metadata elements to describe documents
Metadata elements should be placed in the head element.
1. Set the document title: title element
2. Set the parsing base for relative URLs
The base element can be used to set a base URL for relative links in HTML documents Analyze on this basis. The base element also sets how the link opens when the user clicks it, and how the browser reacts when the form is submitted (described in Chapter 12, Forms).
<!doctype html><html lang="en"><head> <meta charset="UTF-8"> <title>Base Test</title> <!-- 指定相对URL的基准URL --> <base href="http://avatar.csdn.net"> <!-- 指定链接打开方式为:当前页面 --> <base target="_self"></head><body> <!-- 图片地址:http://www.php.cn/ --> <img src="/static/imghwm/default1.png" data-src="/1/4/A/1_ligang2585116.jpg" class="lazy" alt="奋飞"> <a href="http://http://www.php.cn/">PHP中文网</a></body></html>
Note: If you do not specify a base URL, the browser will identify the URL of the current document as the parsing base for all relative URLs.
3. Use metadata to describe the document
The meta element can be used to define various metadata of the document; each meta element can only be used for one purpose.
(1) Specify the name/value metadata pair
You need to use its name and content attributes. 5 predefined metadata names are provided.
Metadata name | Description |
---|---|
The name of the web application system to which the current page belongs | |
The author name of the current page | |
Description of the current page | |
The name of the software used to generate HTML | |
A batch of comma-separated strings used to describe the content of the page |
Description: Tell the browser how to classify and grade the content, In the past, the main method was to use keywords metadata. It is now devalued due to its misuse to create the illusion of page content and relevance. (2) Meta is widely used
<!-- 文档内容的字符编码 --> <meta charset="UTF-8"> <meta http-equiv="content-type" content="text/html charset=UTF-8"> <!-- 5s后刷新当前页面 --> <meta http-equiv="refresh" content="5"> <!-- 5s后跳转到MyBlog --> <meta http-equiv="refresh" content="5; http://www.php.cn/">4. Define CSS styles The style element is used to define the CSS style embedded in the HTML document, and the link element is used to import the CSS style in the external style sheet. style.
(1) Specify the media to which the style applies
media attribute can be used to indicate under what circumstances the document should use the style defined in this element.
Description | |
---|---|
All devices (Default) | ##aural |
braille | |
handheld | |
projection | |
#screen | |
tty | |
tv | |
It should be noted that , when using the above media attributes, you need to conduct comprehensive testing and prepare unavailable backup styles.
(2) Specify external resources The link tag also supports the media attribute. Among them, the ref attribute determines how the browser treats the link element.
#help | |
icon | |
license | |
stylesheet | |
<!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8"> <title>Link Test</title> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /></head><body></body></html> 注意:如果网站标志文件位于项目根目录下,就无需使用link元素加载,其会自动请求加载该文件。 三、使用脚本元素与脚本相关的有两个元素:第一个是script,定义脚本并控制其执行过程;第二个是noscript,规定浏览器不支持脚本或禁用脚本情况的处理方法。 <!-- 未启用或不支持脚本 --><noscript> <!-- 5s后跳转到http://www.php.cn/ --> <meta http-equiv="refresh" content="5; http://www.php.cn/"></noscript> |
The above is the detailed content of A detailed introduction to HTML5-creating HTML documents. For more information, please follow other related articles on the PHP Chinese website!

Best practices for H5 code include: 1. Use correct DOCTYPE declarations and character encoding; 2. Use semantic tags; 3. Reduce HTTP requests; 4. Use asynchronous loading; 5. Optimize images. These practices can improve the efficiency, maintainability and user experience of web pages.

Web standards and technologies have evolved from HTML4, CSS2 and simple JavaScript to date and have undergone significant developments. 1) HTML5 introduces APIs such as Canvas and WebStorage, which enhances the complexity and interactivity of web applications. 2) CSS3 adds animation and transition functions to make the page more effective. 3) JavaScript improves development efficiency and code readability through modern syntax of Node.js and ES6, such as arrow functions and classes. These changes have promoted the development of performance optimization and best practices of web applications.

H5 is not just the abbreviation of HTML5, it represents a wider modern web development technology ecosystem: 1. H5 includes HTML5, CSS3, JavaScript and related APIs and technologies; 2. It provides a richer, interactive and smooth user experience, and can run seamlessly on multiple devices; 3. Using the H5 technology stack, you can create responsive web pages and complex interactive functions.

H5 and HTML5 refer to the same thing, namely HTML5. HTML5 is the fifth version of HTML, bringing new features such as semantic tags, multimedia support, canvas and graphics, offline storage and local storage, improving the expressiveness and interactivity of web pages.

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

The tools and frameworks that need to be mastered in H5 development include Vue.js, React and Webpack. 1.Vue.js is suitable for building user interfaces and supports component development. 2.React optimizes page rendering through virtual DOM, suitable for complex applications. 3.Webpack is used for module packaging and optimize resource loading.

HTML5hassignificantlytransformedwebdevelopmentbyintroducingsemanticelements,enhancingmultimediasupport,andimprovingperformance.1)ItmadewebsitesmoreaccessibleandSEO-friendlywithsemanticelementslike,,and.2)HTML5introducednativeandtags,eliminatingthenee

H5 improves web page accessibility and SEO effects through semantic elements and ARIA attributes. 1. Use, etc. to organize the content structure and improve SEO. 2. ARIA attributes such as aria-label enhance accessibility, and assistive technology users can use web pages smoothly.


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

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

Dreamweaver CS6
Visual web development tools

Zend Studio 13.0.1
Powerful PHP integrated development environment

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.