Home > Web Front-end > HTML Tutorial > What are the head elements of html documents

What are the head elements of html documents

青灯夜游
Release: 2018-12-19 09:05:19
Original
10074 people have browsed it

The head elements of the html document include:

element, element, element, <style> element, <link> element, <script> element and <base> ;element. <br/><p>The header of the document describes various attributes and information of the document, including the title of the document, its location in the Web, and its relationship with other documents; the header element is used to define these information. This article will introduce you to the head elements of html documents so that you can understand the role of the head elements of html documents. I hope it will be helpful to you. [Video tutorial recommendation: <a href="http://www.php.cn/course/list/11.html" target="_blank">HTML tutorial]<p style="text-align: center;"><img src="https://img.php.cn/upload/article/000/000/024/5c18b67545a8c13What are the head elements of html documents"/ alt="What are the head elements of html documents" ><p><span style="max-width:90%">##html <head> element<strong> The <head> element is used to define the head of the document and is a container for all other head elements. Various attributes and information of the HTML document are defined in the <head> element. <p>Let's take a look at a simple html document, which has the most basic required elements: <p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:html;toolbar:false"><!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>标题</title> </head> <body> </body> </html></pre><div class="contentsignin">Copy after login</div></div></p>As can be seen, the <head> element is located in the <html> tag and < Between the body> tags, include other head elements. <p></p><p><span style="font-size: 18px;">html <meta> element <strong></strong></span></p><meta> element is used to specify the character set, page description, and keywords on the web page , author and other metadata. <p></p> Among them, metadata is mainly provided to browsers, search engines and other web services to better rank web pages. <p></p> Let’s take a look at how to use the <meta> element: <p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:html;toolbar:false;">//定义字符集 <meta charset = "UTF-8" > //为搜索引擎定义关键字 <meta name = "keywords" content = "php教程,php入门教程,php视频教程,php源码下载,php手册" > //定义网页的说明 <meta name = "description" content = "php中文网提供大量免费、原创、高清的php视频教程,并定期举行公益php培训!" > //定义网页的作者 <meta name = "author" content = "php中文网" > //定义每30秒刷新一次文档: <meta http-equiv = "refresh" content = "30" > //控制视口(HTML5提供的新属性) <meta name = "viewport" content = "width = device-width,initial-scale = 1.0" ></pre><div class="contentsignin">Copy after login</div></div></p> Description: The viewport is the user’s visible area on the web page. It varies between devices and looks smaller on a phone than on a computer screen. <p></p><p><span style="font-size: 18px;">html <title> element <strong></strong></span></p><title> element is used to define the title of the document; applicable to all HTML or XHTML documents . <p></p><title>The role of the element:<p></p>1. The title can be defined in the browser tab. <p></p>2. You can provide a title for the page when adding it to favorites. <p></p>3. The title of the page can be displayed in search engine results. <p></p>Example:<p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:html;toolbar:false"><!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>php中文网</title> </head> <body> <p>正文的内容显示在浏览器窗口中。</p> <p>title元素的内容显示在浏览器标签,收藏夹和搜索引擎结果中。</p> </body> </html></pre><div class="contentsignin">Copy after login</div></div></p>Rendering:<p></p><p style="text-align: center;"><img src="https://img.php.cn/upload/article/000/000/024/5c18b92ec6088231.jpg"/ alt="What are the head elements of html documents" ></p><p>##html <style>Element<strong><span style="max-width:90%"></span></strong>The<style> element is used to set the style of the HTML page. The inline css style code is written within the <style> element. Example: </p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:css;toolbar:false"><style> body {background-color:pink;} h1 {color:red;} p {color:blue;} </style> <h1>这是一个标题</h1> <p>这是一个段落。</p></pre><div class="contentsignin">Copy after login</div></div><p>Rendering: </p><p><br/></p><p style="text-align: center;"><img src="https://img.php.cn/upload/article/000/000/024/5c18babb18bf2202.jpg"/ alt="What are the head elements of html documents" ></p>##HTML <link>Element<p><span style="max-width:90%">## The <strong>#<link> element is used to link external css style sheets to web pages. The basic syntax is: </strong><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:css;toolbar:false"><link rel="stylesheet" href="css文件" /></pre><div class="contentsignin">Copy after login</div></div></span> Example: </p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:css;toolbar:false"><link rel="stylesheet" href="css/style.css" /></pre><div class="contentsignin">Copy after login</div></div><p></p><p>HTML <script> element </p><p><strong><span style="font-size: 18px;"><script> element is Used to define client-side scripts, such as JavaScript. </span></strong>We can include script statements in the <script> element, for example: </p><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false"><script> console.log("<script> 元素"); </script></pre><div class="contentsignin">Copy after login</div></div><p>Output: </p><p></p><p></p>Also through the src attribute Link external script files to the web page, for example: <p style="text-align: center;"><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:js;toolbar:false"><script type="text/javascript" src="js/style.js" ></script></pre><div class="contentsignin">Copy after login</div></div><img src="https://img.php.cn//upload/image/317/724/506/1545124751943473.jpg" title="1545124751943473.jpg" alt="What are the head elements of html documents"/></p><p>HTML <base> element </p><p><span style="max-width:90%"><strong><base> element is used to specify the page The base URL and base target for all relative URLs in . Example: </strong><div class="code" style="position:relative; padding:0px; margin:0px;"><pre class="brush:html;toolbar:false"><base href = “http://www.php.cn” target = “_ blank” ></pre><div class="contentsignin">Copy after login</div></div> Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study. </style>

The above is the detailed content of What are the head elements of html documents. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Previous article:How to use the img tag of html Next article:How to use HTML
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template