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

What are the head elements of html documents

青灯夜游
青灯夜游Original
2018-12-18 17:22:2810042browse

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><pre class="brush:html;toolbar:false"><!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>标题</title> </head> <body> </body> </html></pre>As can be seen, the <head> element is located in the <html> tag and < Between the body> tags, include other head elements. <p><p><span style="font-size: 18px;">html <meta> element <strong><meta> element is used to specify the character set, page description, and keywords on the web page , author and other metadata. <p> Among them, metadata is mainly provided to browsers, search engines and other web services to better rank web pages. <p> Let’s take a look at how to use the <meta> element: <p><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> 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><span style="font-size: 18px;">html <title> element <strong><title> element is used to define the title of the document; applicable to all HTML or XHTML documents . <p><title>The role of the element:<p>1. The title can be defined in the browser tab. <p>2. You can provide a title for the page when adding it to favorites. <p>3. The title of the page can be displayed in search engine results. <p>Example:<p><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>Rendering:<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>##html <style>Element<strong><span style="max-width:90%">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: <pre class="brush:css;toolbar:false"><style> body {background-color:pink;} h1 {color:red;} p {color:blue;} </style> <h1>这是一个标题</h1> <p>这是一个段落。</p></pre><p>Rendering: <p><br/><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" >##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: <pre class="brush:css;toolbar:false"><link rel="stylesheet" href="css文件" /></pre> Example: <pre class="brush:css;toolbar:false"><link rel="stylesheet" href="css/style.css" /></pre><p><p>HTML <script> element <p><strong><span style="font-size: 18px;"><script> element is Used to define client-side scripts, such as JavaScript. We can include script statements in the <script> element, for example: <pre class="brush:js;toolbar:false"><script> console.log("<script> 元素"); </script></pre><p>Output: <p><p>Also through the src attribute Link external script files to the web page, for example: <p style="text-align: center;"><pre class="brush:js;toolbar:false"><script type="text/javascript" src="js/style.js" ></script></pre><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>HTML <base> element <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: <pre class="brush:html;toolbar:false"><base href = “http://www.php.cn” target = “_ blank” ></pre> 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn