Home >Web Front-end >Front-end Q&A >What does html5 header content usually include?
html5 header content usually includes: 1. Web page title defined by title tag; 2. Favicon (small website icon); 3. Encoding method; 4. Website description; 5. Page keywords; 6. Page Author; 7. Viewport (mobile terminal adaptation); 8. CSS style sheet; 9. JavaScript script.
The operating environment of this tutorial: Windows 7 system, HTML5 version, Dell G3 computer.
According to our needs, we can define a large amount of metadata in the HTML header, or we can define little or no metadata at all. Although the head tag is part of the HTML document, its content is not displayed in the browser.
html5 header content
1. Web page title--
<head> <title>PHP中文网</title> </head>
2, Favicon
The small icon to the left of the web page title, specify If his path is not specified, the browser will look for<link rel="icon" href="/favicon.ico" type="image/x-icon" />
3 in the root directory. Encoding method
The specification of the encoding method is placed at the front of the head. , if not specified, the browser will also make a determination based on the server's header, but it may not be accurate.<head> <meta charset="UTF-8"> </head>
tag is used to provide metadata about the HTML document, such as page validity period, page author, keyword list, page description, etc. The data defined by the tag will not be displayed on the page, but will be parsed by the browser.The charset attribute is used to specify the character encoding of the HTML document. In the above example, we set the character encoding of the document to "UTF-8".
4. Website description
<meta name="description" content="这里是对网站的描述">Defining the description information of the page is beneficial to search engines.
5, PageKeywords
<meta name="keywords" content="HTML, HTML教程, HTML入门">Keywords are used to provide search engines with information about the page.
6, Page author
<meta name="author" content="作者名">Author information can be automatically extracted through some content management systems.
7. Viewport (mobile terminal adaptation)
This is very common. Viewport is usually adapted to the mobile terminal, and the page Put it in a virtual window - viewport. If the web page does not use the viewport, it will appear when we open the mobile browser. It is very small, and it can also be moved and zoomed. It is extremely low. The viewport allows web developers to pass its size and dynamics. Set the size of the control elements in the web page content, so that the same effect (scale reduction) as in the web page can be achieved on the browser. , used to better support responsive websites.<meta name="viewport" content="width=device-width, initial-scale=1">
8. Embedded CSS style--
使用
<head> <title>此处书写标题</title> <style> body { background-color: YellowGreen; } h1 { color: red; } p { color: green; } </style> </head>
注意:对于文档中的唯一样式可以使用
9、外部css样式表-- 标签
标签经常用于引用外部 CSS 样式表, 标签中包含两个主要的属性,分别是 rel 和 href。rel 属性用来指示引用文件的类型,href 属性用来设置外部文件的路径。示例代码如下:
<head> <title>此处书写标题</title> <link rel="stylesheet" href="common.css"> </head>
HTML
标签中可以包含任意数量的 标签。
10、JavaScript 脚本
通过script标签嵌入JavaScript 脚本代码或链入脚本文件
<head> <script> document.write("PHP中文网") </script> </head>
<head> <script src="js/test.js"></script> </head>
相关推荐:《html视频教程》
The above is the detailed content of What does html5 header content usually include?. For more information, please follow other related articles on the PHP Chinese website!