Home >Web Front-end >HTML Tutorial >What attributes are there in the head tag?

What attributes are there in the head tag?

不言
不言forward
2019-03-21 11:29:154007browse

The content of this article is about what attributes are in the head tag? It has certain reference value. Friends in need can refer to it. I hope it will be helpful to you.

What's in the head tag?

In every HTML document, there is an indispensable tag: . As a container, it mainly contains tags used to describe the information (metadata) of the HTML document itself. These tags Generally, it will not be displayed on the page. In most cases, it will be seen by browsers and search engines.

The tags that can be used in are: , <base> , <link> , <style> , <meta> , <script> , < noscript> . </p> <p style="white-space: normal;">Meta information tag introduction</p> <p style="white-space: normal;"><title></p> <p> Defines the title of the document, which is displayed on the title bar or tab page of the browser and generally summarizes the entire web page completely. Content. </p> <p style="white-space: normal;"><base></p> <p> Provides a base for all relative URLs on the page. There can only be one <base> tag in a document. </p> <p>Currently I have only observed "Taobao" using this tag. </p> <p style="white-space: normal;"><link></p> <p>Specifies the relationship between external resources and the current document, often in the link style sheet, as shown below: </p> <pre class="brush:php;toolbar:false">&lt;link rel=&quot;stylesheet&quot; href=&quot;xxx.css&quot; type=&quot;text/css&quot;&gt;</pre> <p> Of course, there are many other functions: </p> <ol><li>For example, it is used for SEO, mainly for search engines to see: </li></ol> <pre class="brush:php;toolbar:false">&lt;link rel=&quot;canonical&quot; href=&quot;...&quot;&gt;</pre> <p>In the website, there are often multiple URLs pointing to the same page. The above tags inform the search engines. What is the main URL of the page so that search engines can retain the main page and remove other duplicate pages. </p> <ol><li> Provide RSS subscription: </li></ol> <pre class="brush:php;toolbar:false">&lt;link rel=&quot;alternate&quot; type=&quot;application/rss+xml&quot; title=&quot;RSS&quot; href=&quot;...&quot;&gt;</pre> <p> In addition to being understandable by search engines, the above tags can also be recognized by many browser plug-ins. </p> <ol><li>Represents the page icon: </li></ol> <pre class="brush:php;toolbar:false">&lt;link rel=&quot;icon&quot; href=&quot;https://xxx.png&quot;&gt;</pre> <p>Most browsers will read the resource of this link and display it on the page. </p> <ol><li>Provide preprocessing for pages: </li></ol> <pre class="brush:php;toolbar:false">&lt;link rel=&quot;dns-prefetch&quot; href=&quot;//xxx.com&quot;&gt;</pre> <p>Do dns query for a domain name in advance. Forcing prefetching of domain names can be useful in some cases. </p> <p>For example, on the homepage of the website, force frequently referenced domain names to be pre-resolved throughout the website, even if they are not used on the homepage itself. While the performance of the home page may not be affected, it will improve overall site performance. </p> <p><style></p> <p>Contains the style information of the document. </p> <p><meta></p> <p>A general metadata information representation tag, usually appearing as a key-value pair, such as: <meta name="xxx" content="yyy"> </p> <p>charset attribute</p> <pre class="brush:php;toolbar:false">&lt;meta charset=&quot;UTF-8&quot;&gt;</pre> <p>Starting from HTML5, the above writing method is recommended to use to declare the character encoding used in the current document. It is recommended to put it first in <head>. </p> <p style="white-space: normal;">http-equiv attribute</p> <pre class="brush:php;toolbar:false">&lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=UTF-8&quot;&gt;</pre> <p>In HTML4, the above code was used to declare the character set, but it is now deprecated. </p> <p>In addition to content-type, there are several other values: </p> <p>content-language (obsolete), set-cookie (obsolete), default-style, refresh, content-security- policy</p> <p>Because it is not commonly used, I will not introduce it one by one. It is also quite easy to understand. If you are interested, you can click here to learn more. </p> <p style="white-space: normal;">name attribute</p> <p>In fact, the <meta> tag can be freely defined, as long as the reading and writing parties agree on the format of name and content. Let’s look at an example: </p> <pre class="brush:php;toolbar:false">&lt;meta name=&quot;viewport&quot; content=&quot;width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no&quot;&gt;</pre> <p>The above usage is not in the HTML standard, but it is the de facto standard for mobile development. Here is an explanation of the content in content: </p> <p>width: page width, which can be a positive integer; it can also be a string "device-width", which means it is equal to the device width. height: page height, which can be a positive integer; it can also be a string "device-height", which means it is equal to the device height. initial-scale: Initial scaling. minimum-scale: Minimum scaling ratio. maximum-scale: Maximum scaling ratio. user-scalable: Whether to allow user scaling. In addition to the viewport, the value of the </p> <p>name attribute also has quite a few values: </p> <p>application-name, author, description, generator, keywords, referrer, robots, etc. </p> <p>Similarly, I won’t introduce them one by one. If you are interested, you can click here to learn more. </p> <p><script></p> <p> is used to embed or reference executable scripts. Let’s take a look at some common global attributes of script tags: </p> <p>async</p> <p> Causes the browser to use another thread to download the script, which will not block page rendering. When the script is downloaded, the browser will pause rendering, execute the script, and continue to render the page after execution. </p> <p>async cannot guarantee the execution order of scripts. Whichever script is downloaded first will be executed first. </p> <p>defer</p> <p> will also cause the browser to download the script in parallel, but it will not be executed immediately after the download is completed. Instead, it will wait until the DOM is loaded (that is, the </html> tag has just been read) before executing the script. </p> <p>defer ensures that the scripts are executed in the order they appear on the page. </p> <p>src</p> <p>Define the address that refers to an external script. There should be no embedded scripts in the script tag specifying this attribute. If the script file uses non-English characters, the character encoding should also be noted. For example: </p> <p><script charset="utf-8" src="https://www.example.com/script.js"></script><br>type</p> <p>The default value is text/javascript</p> <p>If you want to know more details about the <script> tag, you can click here. </p> <p><noscript></p> <p>If the script type on the page is not supported or scripting is currently turned off in the browser, define here the alternative content when the script is not executed. </p> <p>Summary</p> <p>This article ends here. In fact, there are still many things about link and meta tags that have not been introduced. Many related tags have special needs and can only be used under specific circumstances. For example, mobile development will use many tags that are not needed on PC. </p> <p> Of course, daily use mainly depends on the needs. For now, I have only used some tags related to viewport and SEO. </p> <p>In view of this, I recommend a good learning method, which is to go to major websites to see what is in their head tags. If you encounter something you have never seen before, search for it, and you will become familiar with it quickly. </p> <p>The websites I have seen here include: "Taobao", "Alibaba", "JD.com", "NetEase Selection", "Qidian Chinese Network", etc. </p> <p>This article has ended here. For more other exciting content, you can pay attention to the <a href="http://www.php.cn/course/list/11.html" target="_blank">HTML Tutorial Video</a> column of the PHP Chinese website! </p> <p></p><p>The above is the detailed content of What attributes are there in the head tag?. For more information, please follow other related articles on the PHP Chinese website!</p></div><div class="nphpQianMsg"><a href="javascript:void(0);">php</a> <a href="javascript:void(0);">JavaScript</a> <a href="javascript:void(0);">html5</a> <a href="javascript:void(0);">html</a> <a href="javascript:void(0);">Cookie</a> <a href="javascript:void(0);">字符串</a> <a href="javascript:void(0);">线程</a> <a href="javascript:void(0);">JS</a> <a href="javascript:void(0);">default</a> <a href="javascript:void(0);">dom</a> <a href="javascript:void(0);">样式表</a> <a href="javascript:void(0);">viewport</a> <a href="javascript:void(0);">http</a> <a href="javascript:void(0);">https</a> <a href="javascript:void(0);">搜索引擎</a> <a href="javascript:void(0);">SEO</a><div class="clear"></div></div><div class="nphpQianSheng"><span>Statement:</span><div>This article is reproduced at:segmentfault.com. If there is any infringement, please contact admin@php.cn delete</div></div></div><div class="nphpSytBox"><span>Previous article:<a class="dBlack" title="How to remove file extensions (.php and .html) from URLs using .htaccess" href="https://m.php.cn/faq/416206.html">How to remove file extensions (.php and .html) from URLs using .htaccess</a></span><span>Next article:<a class="dBlack" title="How to remove file extensions (.php and .html) from URLs using .htaccess" href="https://m.php.cn/faq/416684.html">How to remove file extensions (.php and .html) from URLs using .htaccess</a></span></div><div class="nphpSytBox2"><div class="nphpZbktTitle"><h2>Related articles</h2><em><a href="https://m.php.cn/article.html" class="bBlack"><i>See more</i><b></b></a></em><div class="clear"></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="fluid" data-ad-layout-key="-6t+ed+2i-1n-4w" data-ad-client="ca-pub-5902227090019525" data-ad-slot="8966999616"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><ul class="nphpXgwzList"><li><b></b><a href="https://m.php.cn/faq/348757.html" title="Summary of Html knowledge" class="aBlack">Summary of Html knowledge</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/348804.html" title="How to learn HTML quickly" class="aBlack">How to learn HTML quickly</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/348873.html" title="The difference between html xhtml xml" class="aBlack">The difference between html xhtml xml</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/348884.html" title="The difference between src and href attributes" class="aBlack">The difference between src and href attributes</a><div class="clear"></div></li><li><b></b><a href="https://m.php.cn/faq/348902.html" title="About HTML5 and CSS replacement use" class="aBlack">About HTML5 and CSS replacement use</a><div class="clear"></div></li></ul></div></div><ins class="adsbygoogle" style="display:block" data-ad-format="autorelaxed" data-ad-client="ca-pub-5902227090019525" data-ad-slot="5027754603"></ins><script> (adsbygoogle = window.adsbygoogle || []).push({}); </script><footer><div class="footer"><div class="footertop"><img src="/static/imghwm/logo.png" alt=""><p>Public welfare online PHP training,Help PHP learners grow quickly!</p></div><div class="footermid"><a href="https://m.php.cn/about/us.html">About us</a><a href="https://m.php.cn/about/disclaimer.html">Disclaimer</a><a href="https://m.php.cn/update/article_0_1.html">Sitemap</a></div><div class="footerbottom"><p> © php.cn All rights reserved </p></div></div></footer><script>isLogin = 0;</script><script type="text/javascript" src="/static/layui/layui.js"></script><script type="text/javascript" src="/static/js/global.js?4.9.47"></script></div><script src="https://vdse.bdstatic.com//search-video.v1.min.js"></script><link rel='stylesheet' id='_main-css' href='/static/css/viewer.min.css' type='text/css' media='all'/><script type='text/javascript' src='/static/js/viewer.min.js?1'></script><script type='text/javascript' src='/static/js/jquery-viewer.min.js'></script><script>jQuery.fn.wait = function (func, times, interval) { var _times = times || -1, //100次 _interval = interval || 20, //20毫秒每次 _self = this, _selector = this.selector, //选择器 _iIntervalID; //定时器id if( this.length ){ //如果已经获取到了,就直接执行函数 func && func.call(this); } else { _iIntervalID = setInterval(function() { if(!_times) { //是0就退出 clearInterval(_iIntervalID); } _times <= 0 || _times--; //如果是正数就 -- _self = $(_selector); //再次选择 if( _self.length ) { //判断是否取到 func && func.call(_self); clearInterval(_iIntervalID); } }, _interval); } return this; } $("table.syntaxhighlighter").wait(function() { $('table.syntaxhighlighter').append("<p class='cnblogs_code_footer'><span class='cnblogs_code_footer_icon'></span></p>"); }); $(document).on("click", ".cnblogs_code_footer",function(){ $(this).parents('table.syntaxhighlighter').css('display','inline-table');$(this).hide(); }); $('.nphpQianCont').viewer({navbar:true,title:false,toolbar:false,movable:false,viewed:function(){$('img').click(function(){$('.viewer-close').trigger('click');});}}); </script></body></html>