IT Band of Brothers HTML5 tutorial HTML document header element head

58a95915ee484e8a8fdd308ae6328d27.jpg

 

HTML is a header tag <head>, including some basic description of the statement page, and the JavaScript and CSS, generally can be defined in the head element. It is used to contain information about the current document, such as page titles and keywords. Usually at the head of the content will be displayed directly on the page, but work in another way. Tag may be used much the <head> tag, contains some common as <title>, <base>, <link> and <meta> tag and the like. Must <title> between <head> and </ head>.

 

<Title> element

The browser will use a special way to the title, and it is usually placed on the browser window's title bar or status bar. When writing each page, you should specify a title to it. The title of the HTML file using the <title> element, <title> is <head> child elements for content displayed in the title bar of the browser, for use documentation, and a list of links to a document when adding users or when favorites or bookmarks list, the title will become the default name of the linked document. Every HTML document should have a title, after the viewer save the page to be saved when the page file name. In addition, the search engine at the time of collection of the page, the page title as a keyword search, and as the title displayed on the search engine pages. The basic syntax is as follows:

<Title> Band of Brothers IT Education: HTML5 discipline </ title> <- title tags defined in the head -!>

The title describes the actual site content is very important. For example, the main page of the site should not only use the "Home" label, but should be able to describe the use of site content statements are usually "company name + the company's products." For good page title, a visitor after reading it should be able to understand the content of the page, without the need to view the actual content of the page.

note

一个文档只能使用一个<title>元素,<title>元素中只能包含关于页面标题的文本,而不能包含其他任何元素。另外,<title>标签是<head>标签中唯一要求包含的东西。

 

<base>元素

在页面中使用<a>、<img>、<link>、<form> 标签,都需要指定URL。通常情况下,如果在URL中使用相对路径,浏览器会从当前文档的URL中提取相应的元素来填写相对URL路径中的空白。而<base> 标签为页面上的所有链接规定默认地址或默认目标,浏览器随后将不再使用当前文档的URL,而使用指定的基本URL来解析所有的相对URL。在网页文档中,所有的相对地址形式的URL都是相对于这里定义的基URL而言的。例如,如果在<base>中指定基URL为http://www.itxdl.cn,那么在网页中出现的相对链接“test.html”将对应http://www.itxdl.cn/ test.html的页面。因此,如果网页位置发生变化,可以通过修改<base>来适应这一变化。一篇文档中的<base>标记最多只能有一个,而且必须放于头部,并且应该在任何包含URL地址的语句之前。基本语法格式如下所示:

<base href="http://www.itxdl.cn/h5/" target="_blank" />       <!-- base标签使用方法        -->

在<base>标签中href是必需的属性,规定页面中所有相对链接的基准URL。而target是可选属性,设置在何处打开页面中所有的链接。

 

<link>元素

<link>标签定义文档与外部资源的关系,最常见的用途是链接样式表。该元素始终是空元素,它仅包含属性,浏览器会分析<link>中的内容,自动读取并加载相应的文件。基本语法格式如下所示:

<link rel="stylesheet" type="text/css" href="style.css" />       <!-- 在头部链接CSS文件位置  -->

<link>元素只能存在于head部分,不过它可出现任何次数。关于<link>元素的应用将在CSS一章中详细介绍。

 

<meta>元素

<meta>元素可提供有关页面的元信息(meta-information),比如针对搜索引擎和更新频度的描述和关键词,也能够提供文档的作者、描述、编码和语言等多种元信息,但不包含任何内容。该标签位于文档的头部,可以包含任意数量的<meta>标记。该标签的属性定义了与文档相关联的名称/值对,来定义文件信息的名称、内容等。这个标记是实现元数据的主要标记,通过该标记中的http-equiv、name、content属性,可以建立多种多样的效果和功能。基本语法格式如下所示:

<meta name="某个设置值" content="对该设置值进行具体补充说明的信息" />

<meta http-equiv="某个设置值" content="对该设置值进行具体补充说明的信息" />                

下例给出一段包含<head>标记的源代码,以兄弟连IT教育官方网站为例。登录http://www.itxdl.cn后,通过查看源文件的方式即可找到以下的头部信息。

c868e118fd57490db75d296cc2c4405e.png

 

These are some basic usage of header information, the most important thing is to set the <title> tag and <meta> keywords and description of the property. Because these two statements can make the search engine more accurately find your site to attract more people to visit. According to the working principle of the now popular search engine, search engines send robots to automatically search on the WWW. When they find a new site, it will retrieve the page keywords and description, and add it to your database, and then sorted according to the site's keyword density. May be used to specify in HTML5 <meta> element directly additional embodiment charset attribute character encoding, from the beginning HTML5, encoding for the character files recommended UTF-8. As follows:

<meta charset= "UTF-8 ">                         <!--  HTML5  -->

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />     <!--  HTML以前版本  -->

Guess you like

Origin www.cnblogs.com/itxdl/p/11595705.html