The HEAD tag seems to play a less important role in the HTML document. This is because whatever kept in the head element indirectly visible on the browser. But the head element is having an important role in the HTML document for the web browser, as here instructions for the web browser are present also one could some extra and important information of the document about the browser, such information is called the metadata. Most of the metadata of the HTML document is not displayed on the web browser but still, it could be useful for the functionality of the webpage.
HEAD标记在HTML文档中似乎不太重要。 这是因为保留在head元素中的任何内容在浏览器上都是间接可见的。 但是head元素在Web浏览器HTML文档中起着重要的作用,因为此处提供了针对Web浏览器的说明,也可能是文档中有关浏览器的一些额外的重要信息,这种信息称为元数据。 HTML文档的大多数元数据没有显示在Web浏览器上,但是仍然可以用于网页的功能。
The <head> element also contains some other HTML tags which then contain the metadata. The other elements present in the HEAD tag, are in a nested form with the <head> tag as the outermost element.
<head>元素还包含其他一些HTML标记,这些标记随后包含元数据。 HEAD标记中存在的其他元素为嵌套形式,其中<head>标记为最外面的元素。
The syntax for the HEAD tag,
HEAD标记的语法,
<html>
<head>
<!--other sub tags of HEAD tag-->
<!--Scripts & CSS(s) etc.-->
</head>
<body>
<p>
The head element of this document is not <br>
directly visible on the web browser.
</p>
</body>
</html>
The output of the above code would be as follows,
上面代码的输出如下:
In the above example, the body element is visible to the viewer. The content in the body is display by the browser while the contents of the head are for the browser.
在上面的示例中,body元素对于查看者可见。 身体中的内容由浏览器显示,而头部的内容由浏览器显示。
<title>元素 (The <title> element)
The HEAD element also contains the TITLE element. The TITLE element is used to provide the title of the webpage. This title is visible to the user or visitor who visits the webpage. The title of the webpage on given in the title bar of the web browser.
HEAD元素还包含TITLE元素 。 TITLE元素用于提供网页标题。 该标题对访问网页的用户或访问者可见。 网页的标题位于网络浏览器的标题栏中。
The below example shows the use of the TITLE tag of HTML,
以下示例显示了HTML的TITLE标记的用法,
<html>
<head>
<!--Title tag--->
<title>The title tag in HTML </title>
<!--End of Title tag-->
</head>
<body>
<p>See the title of the page on the title bar.</p>
</body>
</html>
The output for the above code is as follows,
上面代码的输出如下:
<style>元素 (The <style> element)
The style element is used to provide styling on the webpage. The <style> tag use the classes, ids or the element to provide them internal styling.
样式元素用于在网页上提供样式。 <style>标记使用类,id或元素为它们提供内部样式。
For example,
例如,
The output of the above code is as follows,
上面代码的输出如下:
<link>元素 (The <link> element)
The <link> element is used to link to an external file to the HTML document. This external file could be the style sheets, for example:
<link>元素用于链接到HTML文档的外部文件。 该外部文件可以是样式表,例如:
<link href="externalCSSfile.css" rel="stylesheet">