", 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?
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.
The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.
html5 document must have 4 tags
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>文档标题</title> </head> <body> 文档内容...... </body> </html>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;<!DOCTYPE HTML>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.
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.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
tagelement 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.<body> <p>一个段落</p> <img src="img/1.jpg" style="max-width:90%" / alt="What tags must html5 documents have?" ><br><br> <button>一个按钮</button><br><br> <input type="text" value="输入框" /> </body>
Note: Only one
tag can exist in an HTML file. Extended knowledge: Elements that can be included in the head tag##1.
注意,在
在浏览器标题栏或者任务栏中显示标题;
当将页面添加到收藏夹(书签)时提供标题;
在搜索结果中显示页面标题。
下面的示例演示了如何在 HTML 文档中使用
<head> <meta charset="utf-8"> <title>php中文网-教程_手册_视频-免费php在线学习平台</title> </head>
2、
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title><base>标签演示</title> <base href="https://www.php.cn/"> </head> <body> <ul> <li><a href="course.html">视频教程</a></li> <li><a href="course/type/3.html">入门教程</a></li> </ul> </body> </html>
上面的示例中第一个
注意,HTML 文档中的
3、 标签
标签经常用于引用外部 CSS 样式表, 标签中包含两个主要的属性,分别是 rel 和 href。rel 属性用来指示引用文件的类型,href 属性用来设置外部文件的路径。示例代码如下:
<head> <title>此处书写标题</title> <link rel="stylesheet" href="common.css"> </head>
HTML
标签中可以包含任意数量的 标签。4、
使用
<head> <title>此处书写标题</title> <style> body { background-color: YellowGreen; } h1 { color: red; } p { color: green; } </style> </head>
注意:对于文档中的唯一样式可以使用
5、 标签
标签用于提供有关 HTML 文档的元数据,例如页面有效期、页面作者、关键字列表、页面描述等信息。 标签定义的数据并不会显示在页面上,但却会被浏览器解析。
1) 定义字符集
<meta charset="UTF-8">
charset 属性用来指定 HTML 文档的字符编码,上面的示例中,我们将文档的字符编码设置为了“UTF-8”。
2) 定义页面描述
<meta name="description" content="php中文网提供大量免费、原创、高清的php视频教程,并定期举行公益php培训!可边学习边在线修改示例代码,查看执行效果!php从入门到精通,一站式php自学平台!">
定义页面的描述信息有利于搜索引擎的搜索。
标签定义文档标题,name="description" 定义文档描述,描述的长度通常大于标题。
3) 定义关键字
<meta name="keywords" content="php教程,php入门教程,php视频教程,php源码下载,php手册">
关键字用于为搜索引擎提供与页面有关的信息。
4) 定义页面作者
<meta name="author" content="PHP中文网">
通过某些内容管理系统可以自动提取作者信息。
5) 刷新页面
<meta http-equiv="refresh" content="30">
上例中的代码用于向浏览器发送一个指令,使浏览器在经过指定的时间间隔(30 秒)后自动刷新页面。在 content 属性中除了可以指定时间间隔外,还可以再指定一个链接,这时页面将在指定的时间后重定向到链接所指向的页面,如下例所示:
<meta http-equiv="refresh" content="10; url=https://www.php.cn/">
6、<script> 标签</script>
<script> 标签用于定义 JavaScript 脚本,示例代码如下:</script>
<head> <title>PHP中文网</title> <script> document.write("PHP中文网") </script> </head>
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!