<head>
HTML <head> Tag
Instance
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>文档标题</title> </head> <body> 文档内容...... </body> </html>
Run Example»
Click the "Run Instance" button to view the online instance
Browser support
##All major browsers support the <head> tag .Tag definition and usage instructionsThe<head> element is the container for all head elements. The <head> element must contain the title of the document and can contain scripts, styles, meta information and more. The elements listed below can be used inside the <head> element:
- <title> (In the head, this element is required)
- <style> ##<base>
- ##<link>
- <meta>
##<script>
- ##<noscript>
Differences between HTML 4.01 and HTML5
HTML5 no longer supports the profile attribute.
Properties
Properties
profile | ||
---|---|---|
HTML5 Not supported. A series of rules that specify document URLs. These rules are recognized by the browser and accurately read the information in the content attribute of the <meta> tag. | Global attributesThe<head> tag supports HTML global attributes. Try it - ExampleUsing the <base> tag in <head> Instance<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <base href="//m.sbmmt.com//images/" target="_blank"> </head> <body> <p><img src="logo.png" > - 注意这里我们设置了图片的相对地址。能正常显示是因为我们在 head 部分设置了 base 标签,该标签指定了页面上所有链接的默认 URL,所以该图片的访问地址为 "//m.sbmmt.com/images/logo.png"</p> <p><a href="//m.sbmmt.com/">php.cn</a> - 注意这个链接会在新窗口打开,即便它没有 target="_blank" 属性。因为在 base 标签里我们已经设置了 target 属性的值为 "_blank"。</p> </body> </html> Run instance» Click the "Run instance" button to view the online instance Using the <style> tag in <head> Instance<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <style type="text/css"> h1 {color:red;} p {color:blue;} </style> </head> <body> <h1>这是一个标题</h1> <p>这是一个段落。</p> </body> </html> Run instance» Click the "Run instance" button to view the online instance Using the <link> tag in <head> Instance<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>php中文网(php.cn)</title> <link rel="stylesheet" type="text/css" href="styles.css"> </head> <body> <h1>我是通过样式文件 styles.css 渲染后显示的。</h1> <p>我也是。</p> </body> </html> Run instance» Click the "Run instance" button to view the online instance Related ArticlesHTML Tutorial: HTML Header |