Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

An html5 document must have a tag

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)05/31 Report--

Most people do not understand the knowledge of this "html5 document must have which tag" article, so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "html5 document must have which tag" article.

There must be four tags: 1, ",", which is a standard generic markup language document type declaration; 2, ",", which is used to tell the browser that it is an HTML document; 3, ",", which contains the metadata of the document; 4, ",", which contains the content that visitors can see.

The operating environment of this tutorial: windows7 system, HTML5 version, Dell G3 computer.

Html5 documents must have 4 tags

An HTML document is a description of a document that has a fixed structure and is divided into many parts, each of which contains one or more elements. Some elements describe the basic information of the document, others describe the structure of the document. Here is the structure of a basic HTML document.

Document title document content.

The HTML document describes a blank page, and these basic components determine the outline of the HTML document and the initial environment of the browser.

1. Label

DOCTYPE is an abbreviation for document type (document type).

The doctype declaration is a standard generic markup language document type declaration that is used in web design to indicate what version of XHTML or HTML you are using.

It tells the browser two things:

It deals with HTML documents

The version of the HTML used to mark the content of the document, which is written below indicates that you are using HTML5.

There is only one html5 doctype declaration:

The declaration must be on the first line of the HTML5 document, that is, before the tag. This tag tells the browser the HTML specification used by the document.

Note: the doctype declaration is not a HTML tag, but a document type tag, which is an instruction.

Description:

The label does not have an end tag.

Insensitive to case.

2. Label

Tags are the outermost elements in an HTML document.

Tags are containers for all other HTML elements (except tags).

The function of the root element is to tell the browser that the content between and is of type HTML, and the browser parses the content by HTML.

The html element has three attributes, namely the lang attribute, the xmlns attribute, and the manifest attribute:

The lang property specifies the default language used by the page content. Specifying the language used by the document helps the language synthesis tool choose the pronunciation language, or the translation tool selects translation rules. For example, indicates that this document is in Chinese.

The xmlns attribute assigns the namespace of the XML. The xmlns attribute is required in XHTML, but not in HTML.

The manifest attribute gives the URL of the offline cache file. HTML5 introduces application caching, which means that web applications can be cached and accessed offline. For example, indicates that the offline cache file is waibo.manifest.

3. Label

Tags are containers for all header tags, which are used to define metadata about HTML documents (data that describes the data) and references to required resources (such as CSS style files, JavaScript script files), which play a very important role in the correct display of the document in the browser.

Depending on our requirements, a large amount of metadata can be defined in the HTML header, or there can be little or no definition at all. Although the header tag is part of the HTML document, the contents are not displayed in the browser.

4. Label

Element defines the body of the document.

Elements contain all the contents of the document, such as text, hyperlinks, images, tables, lists, and so on.

To put it simply: the body section of the document contains content that visitors can see.

With this basic structure, we can gradually add other elements of HTML, constantly enrich the document, and finally get the page we want.

A paragraph

A button.

Note: only one tag can exist in a HTML file.

Extended knowledge: elements that can be contained in head header tags

1. Label

Tags are used to define the title of an HTML document, and only a document that contains tags is a valid HTML document. In addition, only one tag is allowed in an HTML document, and the tag must be placed in the tag.

Note that only plain text content is allowed inside the tag, not other HTML tags.

The main purpose of the label is as follows:

Display the title in the browser title bar or taskbar

Provide a title when adding a page to your favorites (bookmark)

Displays the page title in the search results.

The following example shows how to use tags in an HTML document:

-tutorial _ manual _ video-free php online learning platform

The content of the tag must be related to the current document and should not be too long. Please try to limit the Chinese page to 30 characters (including spaces).

2. Label

The tag is used to specify a base link for all relative links on the page, and when you set the basic link, all relative links on the current page are prefixed with this basic link, as shown in the following example:

Tag demo video tutorials getting started

In the above example, the hyperlink in the first tag will be resolved to "https://www.yisu.com/course.html", and the hyperlink in the second will be resolved to" https://www.yisu.com/course/type/3.html".

Note that tags in HTML documents must appear before any tags that reference external resources, and only one tag is allowed to be defined in an HTML document.

3. Label

Tags are often used to reference external CSS stylesheets, and the tags contain two main attributes, rel and href. The rel attribute is used to indicate the type of reference file, and the href property is used to set the path to the external file. The sample code is as follows:

Write the title here

HTML tags can contain any number of tags.

4. Label

Using tags, you can embed CSS styles in an HTML document, and it is important to note that the styles defined in the tags are valid only for the current HTML document. The sample code is as follows:

Write the title body {background-color: YellowGreen;} H2 {color: red;} p {color: green;} here

Note: tags can be used for unique styles in a document, but external style sheets are more appropriate for styles that are common in multiple documents. For more information about embedding CSS in HTML, go to "HTML embedding CSS style (four ways)."

5. Label

Tags are used to provide metadata about HTML documents, such as page validity, page author, keyword list, page description, and so on. The data defined by the tag is not displayed on the page, but it is parsed by the browser.

1) define the character set

The charset property is used to specify the character encoding of the HTML document. In the above example, we set the character encoding of the document to "UTF-8".

2) define the page description

Defining the description information of the page is beneficial to the search of search engines.

The tag defines the document title, and the name= "description" defines the document description, which is usually longer than the title.

3) define keywords

Keywords are used to provide search engines with page-related information.

4) define the author of the page

Author information can be extracted automatically through some content management systems.

5) refresh the page

The code in the example above is used to send an instruction to the browser to automatically refresh the page after a specified interval of 30 seconds. In addition to specifying the time interval, you can also specify a link in the content attribute, where the page will be redirected to the page that the link points to after the specified time, as shown in the following example:

6. Label

The tag is used to define the JavaScript script. The sample code is as follows:

[xss_clean] (")

7. Label

When the user's browser does not support JavaScript scripts or disable JavaScript scripts, you can define something in the tag to replace JavaScript scripts that cannot be run or give the user some hints. In addition to tags, you can include any HTML element in the tag, as shown in the following example:

Your browser does not support JavaScript or you have disabled JavaScript, please click here to learn how to enable JavaScript.

The above is about the content of this article "html5 documents must have which tag". I believe we all have a certain understanding. I hope the content shared by the editor will be helpful to you. If you want to know more about the relevant knowledge, please pay attention to the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report