3    Head Data of an HTML DocumentHTML文档的头部数据

The head data between <head> and </head> contains important information and data about an HTML document that’s used by web browsers or search engines. <head></head>之间的head数据包含有关web浏览器或搜索引擎使用的HTML文档的重要信息和数据。In this chapter, you’ll get to know the HTML elements for the head data of an HTML document in more detail.在本章中,您将更详细地了解HTML文档头部数据的HTML元素。

In the head of the HTML document between <head> and </head>, you can insert various HTML elements that enable you to control the content and the display of a web page. <head></head>之间的HTML文档头部,您可以插入各种HTML元素,使您能够控制网页的内容和显示。You can also establish the relationships between the web browser and other pages or documents here. 您还可以在此处建立web浏览器与其他页面或文档之间的关系。The content you write in the head element doesn’t get displayed by the web browser, except for the title element. 除了title元素外,您在head元素中写的内容不会被web浏览器显示。An overview of the different HTML elements, which you can write in the head section between <head> and </head>, is followed by the description of the individual HTML elements.您可以在<head></head>之间的头部部分编写不同HTML元素的概述,然后是对单个HTML元素的描述。

This chapter may not be spectacular and exciting, but even the nonvisible parts in the head of an HTML document are part of the essential basics of HTML. 本章可能并不壮观和令人兴奋,但即使是HTML文档头部不可见的部分也是HTML基本知识的一部分。If you’re in a rush, I recommend that you at least take a look at the sections on the <meta> elements (Section 3.8.1, specifically the character encoding) and <title> (Section 3.2). 如果你赶时间,我建议你至少看看关于<meta>元素(第3.8.1节,特别是字符编码)和<title>第3.2节)的部分。For the time being, these two headers are the most important elements for the next chapters. For all other HTML elements for head data, you can always look them up here if needed.目前,这两个标题是下一章最重要的元素。对于头部数据的所有其他HTML元素,如果需要,您可以随时在此处查找。

3.1    Overview of HTML Elements for the Head头部HTML元素概述

You must write the head element with the head data of an HTML document directly after the opening <html> tag and before the document body with the body element. 您必须在打开<HTML>标签之后,在带有body元素的文档正文之前,直接用HTML文档的头部数据写入head元素。You can use the elements from Table 3.1 or Figure 3.1 between <head> and </head> (the order doesn’t matter). 您可以在<head></head>之间使用表3.1或图3.1中的元素(顺序无关紧要)。Of the elements listed in Table 3.1, you must specify at least the title element.在表3.1中列出的元素中,您必须至少指定title元素。

HTML ElementHTML元素

Meaning意思

<title>...</title>

Contains the title of the HTML document.包含HTML文档的标题。

<base>

Sets base URLs/targets for all relative URLs in a web page.为网页中的所有相对URL设置基本URL/目标。

<link>

Sets logical links of the HTML document to other files to be included.设置HTML文档到要包含的其他文件的逻辑链接。

<style>

Sets the local stylesheet rules for the HTML document.为HTML文档设置本地样式表规则。

<script>

Integrates the client-side scripts. The script element isn’t restricted to the HTML document header and may also appear (multiple times) in the document body.集成客户端脚本。script元素不限于HTML文档头,也可能(多次)出现在文档正文中。

<meta>

Sets the metadata such as keywords, descriptions, or the character set for the HTML document.设置元数据,如关键字、描述或HTML文档的字符集。

Table 3.1     Elements That Can Be Used in the HTML Document Head between <head> and </head>可以在<Head></Head>之间的HTML文档头中使用的元素

In the Head Element between the <head> and </head> Tags, You Can Use the <title>, <base>, <link>, <style>, <script>, and <meta> Elements

Figure 3.1     In the Head Element between the <head> and </head> Tags, You Can Use the <title>, <base>, <link>, <style>, <script>, and <meta> Elements<Head></Head>标签之间的Head元素中,您可以使用<title><base><link><style><script><meta>元素