HTML header
HTML <head>
View online example
Example
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>我的 HTML 的第一页</title> </head> <body> <p>浏览器中包含body元素的内容。</p> <p>浏览器的标题包含title元素的内容</p> </body> </html>
Run instance»
Click the "Run instance" button to view the online instance
Use <base> to define the default link target address of all links on the page .
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <base href="http://www.php.cn/images/" target="_blank"> </head> <body> <img src="logo.png"> - 注意这里我们设置了图片的相对地址。能正常显示是因为我们在 head 部分设置了 base 标签, 该标签指定了页面上所有链接的默认 URL,所以该图片的访问地址为 "http://www.php.cn/images/logo.png" <br><br> <a href="http://www.php.cn">php中文网</a> - 注意这个链接会在新窗口打开,即便它没有 target="_blank" 属性。 因为在 base 标签里我们已经设置了 target 属性的值为 "_blank"。 </body> </html>
Run Instance»
Click the "Run Instance" button to view the online instance
Use the <meta> element to describe the description, keywords, author, character set, etc. of the HTML document.
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <meta name="description" content="Free Web tutorials"> <meta name="keywords" content="HTML,CSS,XML,JavaScript"> <meta name="author" content="Ståle Refsnes"> <meta charset="UTF-8"> </head> <body> <p>所有 meta 标签显示在 head 部分...</p> </body> </html>
Run Instance»
Click the "Run Instance" button to view the online instance
HTML <head> element
<head> element contains all head tag elements. exist In the <head> element, you can insert scripts, style files (CSS), and various meta information.
The element tags that can be added in the header area are: <title>, <style>, <meta>, <link>, <script>, <noscript>, and < base>.
HTML <title> Element
<title> tag defines the title of different documents.
<title> is required in HTML/XHTML documents.
<title> Element:
Defines the title of the browser toolbar
When a web page is added to favorites The title that is displayed in favorites
The title that is displayed in the search engine results page
A simple HTML document:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>文档标题</title> </head> <body> 文档内容...... </body> </html>
HTML <base> element
<base> tag describes the basic link address/link target, which serves as the default link for all link tags in the HTML document:
<head> <base href="http://www.php.cn/images/" target="_blank"> </head>
HTML <link> Element The
<link> tag defines the relationship between the document and external resources. The
<link> tag is typically used to link to a style sheet:
<head> <link rel="stylesheet" type="text/css" href="mystyle.css"> </head
##HTML <style> element
The
<style> tag defines the reference address of the style file of the HTML document.In the <style> element you need to specify the style file to render the HTML document:<head> <style type="text/css"> body {background-color:yellow} p {color:blue} </style> </head
meta tag describes some basic metadata. The
<meta> tag provides metadata. Metadata is also not displayed on the page, but will be parsed by the browser.
The META element is typically used to specify a web page's description, keywords, the file's last modification time, author, and other metadata.
Metadata can be used by browsers (how to display content or reload pages), search engines (keywords), or other web services.
<meta> is generally placed in the <head> area
<meta> tag - usage example
Define keywords for search engines:
<meta name="keywords" content="HTML, CSS, XML, XHTML, JavaScript"
<meta name="description" content="Free Web tutorials on HTML and CSS"
<meta name="author" content="Hege Refsnes"
<meta http-equiv="refresh" content="30"
HTML <script> element
<script> tag is used to load script files, such as JavaScript. The
<script> element will be described in detail in the following chapters.
HTML head element
Tag | Description |
---|---|
<head> | defines the information of the document |
##<title> | defines the information of the document Title|
<base> | defines the default link address of the page link tag|
<link> | Defines the relationship between a document and external resources|
<meta> | Defines the metadata in the HTML document|
<script> | Defines the client script file|
<style> | Defines the style file of the HTML document