", which is a document type declaration of a standard universal markup language; 2. "", which is used to inform the browser that it is an HTML document; 3. "" contains the metadata of the document; 4. "" contains the content that visitors can see."/> ", which is a document type declaration of a standard universal markup language; 2. "", which is used to inform the browser that it is an HTML document; 3. "" contains the metadata of the document; 4. "" contains the content that visitors can see.">

Home>Article>Web Front-end> What tags must html5 documents have?

What tags must html5 documents have?

青灯夜游
青灯夜游 Original
2022-05-18 15:56:50 6544browse

There must be 4 tags: 1. "", which is a document type declaration of a standard universal markup language; 2. "", which is used to inform the browser of its Itself is an HTML document; 3. "

" contains the metadata of the document; 4. "" is used to contain content that visitors can see.

What tags must html5 documents have?

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

html5 document must have 4 tags

  • ##

  • ##

  • #

  • HTML document is a description of a document. It has a fixed structure and is divided into many parts. Each part contains one or more elements. Some elements are used to describe the basic information of the document, and some describe the document structure. The following is the structure of a basic HTML document
  •     文档标题 
    
    文档内容......
This HTML document describes a blank page. These basic components determine the outline of the HTML document. and the browser's initial environment.

1. tag

DOCTYPE is the abbreviation of document type.

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

It tells the browser two things:

It processes HTML documents;
  • is used to mark document content The version of HTML that is used. The following writing method indicates that HTML5 is used.
  • html5 There is only one doctype declaration:
  • 
          
The declaration must be located on the first line in the HTML5 document, that is, before the tag . This tag tells the browser the HTML specification used by the document.

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

Explanation:

tag has no closing tag.
  • is not case sensitive.
  • 2. tag

tag is the outermost element in an HTML document. The

tag is a container for all other HTML elements (except the tag).

The function of the root element is to tell the browser that the content between and is of HTML type, and the browser will parse the content as HTML. The

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

lang attribute specifies the default language used for page content. Specifying the language in which the document is written helps a language synthesis tool choose a pronunciation language, or a translation tool choose translation rules. For example, means that this document is in Chinese.
  • xmlns attribute assigns the XML namespace. 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 web applications can be cached and accessed offline. For example, means that the offline cache file is waibo.manifest.
  • 3. tag

tag is a container for all head tags. These head tags are used to Defining metadata about the HTML document (data that describes the data) and references to the required resources (such as CSS style files, JavaScript script files) play a very important role in enabling the document to be displayed correctly in the browser.

According to our needs, we can define a large amount of metadata in the HTML header, or we can define little or no metadata at all. Although the head tag is part of the HTML document, its content is not displayed in the browser.

4. The

tag

element defines the body of the document. The

element contains all the content of the document, such as text, hyperlinks, images, tables, lists, etc.

Simply put: the body part of the document contains the content that visitors can see.

After having this basic structure, we can gradually add other elements of HTML later, continuously enrich the document, and finally get the page we want.

 

一个段落

What tags must html5 documents have?



Note: Only one

tag can exist in an HTML file. What tags must html5 documents have?

Extended knowledge: Elements that can be included in the head tag

##1.tag

标签用来定义 HTML 文档的标题,只有包含 <title> 标签的文档才算是一个有效的 HTML 文档。另外,一个 HTML 文档中仅允许存在一个 <title> 标签,并且 <title> 标签必须放置在 标签中。<p>注意,在 </p> <title> 标签内部仅允许包含纯文本内容,不能包含其他 HTML 标签。<p></p> <title> 标签的主要作用如下所示:<ul style="list-style-type: disc;"> <li><p>在浏览器标题栏或者任务栏中显示标题;</p></li> <li><p>当将页面添加到收藏夹(书签)时提供标题;</p></li> <li><p>在搜索结果中显示页面标题。</p></li> </ul> <p>下面的示例演示了如何在 HTML 文档中使用 </p> <title> 标签:<pre class="brush:html;toolbar:false"><head> <meta charset="utf-8"> <title>php中文网-教程_手册_视频-免费php在线学习平台

标签的内容必须与当前文档有关,并且不应该过长,中文页面请尽量控制在 30 个字符(包括空格)以内。<p><strong>2、<base> 标签</strong></p> <p><base> 标签用于为页面中所有相对链接指定一个基本链接,当您设置了基本链接后,当前页面中的所有相对链接都会使用这个基本链接作为前缀,如下例所示:</p><pre class="brush:html;toolbar:false"><!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title><base>标签演示

上面的示例中第一个

  • 标签中的超链接会被解析为“//m.sbmmt.com/course.html”,第二个
  • 中的超链接会被解析为“//m.sbmmt.com/course/type/3.html”。

    注意,HTML 文档中的 标签必须出现在任何引用外部资源的标签之前,而且一个 HTML 文档中仅允许定义一个 标签。

    3、 标签

    标签经常用于引用外部 CSS 样式表, 标签中包含两个主要的属性,分别是 rel 和 href。rel 属性用来指示引用文件的类型,href 属性用来设置外部文件的路径。示例代码如下:

     此处书写标题  
    

    HTML

    标签中可以包含任意数量的 标签。

    4、

    使用

     此处书写标题  
    

    注意:对于文档中的唯一样式可以使用

    5、 标签

    标签用于提供有关 HTML 文档的元数据,例如页面有效期、页面作者、关键字列表、页面描述等信息。 标签定义的数据并不会显示在页面上,但却会被浏览器解析。

    1) 定义字符集

    charset 属性用来指定 HTML 文档的字符编码,上面的示例中,我们将文档的字符编码设置为了“UTF-8”。

    2) 定义页面描述

    定义页面的描述信息有利于搜索引擎的搜索。

    标签定义文档标题,name="description" 定义文档描述,描述的长度通常大于标题。

    3) 定义关键字

    关键字用于为搜索引擎提供与页面有关的信息。

    4) 定义页面作者

    通过某些内容管理系统可以自动提取作者信息。

    5) 刷新页面

    上例中的代码用于向浏览器发送一个指令,使浏览器在经过指定的时间间隔(30 秒)后自动刷新页面。在 content 属性中除了可以指定时间间隔外,还可以再指定一个链接,这时页面将在指定的时间后重定向到链接所指向的页面,如下例所示:

    6、

     PHP中文网  
    

    7、

    当用户的浏览器不支持 JavaScript 脚本或者禁用 JavaScript 脚本时,可以在

    The above is the detailed content of What tags must html5 documents have?. For more information, please follow other related articles on the PHP Chinese website!

  • Statement:
    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