优秀的编程知识分享平台

网站首页 > 技术文章 正文

HTML5文档头部相关标签怎样使用?(html5header标签)

nanyue 2025-03-25 16:02:45 技术文章 10 ℃

制作网页时,经常需要设置页面的基本信息,如页面的标题、作者、和其他文档的关系等。为此HTML提供了一系列的标签,这些标签通常都写在head标签内,因此被称为头部相关标签。本节将具体介绍常用的头部标签。

1.设置页面标题标签</p><p data-track='3'><title>标签用于定义HTML页面的标题,即给网页取一个名字,该标签必须位于<head>标签之内。一个HTML文档只能包含一对<title>标签,之间的内容将显示在浏览器窗口的标题栏中。例如将页面标题设置为“轻松学习HTML5”,具体代码如下:

轻松学习HTML5

上述代码对应的页面标题效果如图1所示。

图 1设置页面标题标签</p></div><p data-track='7'>2.定义页面元信息标签<meta /></p><p data-track='8'><meta />标签用于定义页面的元信息(元信息不会显示在页面中),可重复出现在<head>头部标签中。在HTML中,<meta />标签是一个单标签,本身不包含任何内容,仅仅表示网页的相关信息。通过<meta />标签的两组属性,可以定义页面的相关参数。例如为搜索引擎提供网页的关键字、作者姓名、内容描述,以及定义网页的刷新时间等。下面介绍<meta />标签常用的几组设置,具体如下。</p><p data-track='9'>1)<meta name='名称' /></p><p data-track='10'>在<meta />标签中使用name和content属性可以为搜索引擎提供信息,其中name属性用于提供搜索内容的名称,content属性提供对应的搜索内容值,具体应用如下。</p><p data-track='11'>●设置网页关键字,例如某图片网站的关键字设置:</p><pre class="prism-highlight prism-language-bash" class='syl-page-code'><code><meta name='keywords' /></code></pre><p data-track='13'>其中name属性的值为keywords,用于定义搜索内容名称为网页关键字,content属性的值用于定义关键字的具体内容,多个关键字内容之间可以用“,”分隔。</p><p data-track='14'>●设置网页描述,例如某图片网站的描述信息设置:</p><pre class="prism-highlight prism-language-bash" class='syl-page-code'><code><meta name='description' /></code></pre><p data-track='16'>其中name属性的值为description,用于定义搜索内容名称为网页描述,content属性的值用于定义描述的具体内容。需要注意的是网页描述的文字不必过多,能够描述清晰即可。</p><p data-track='17'>●设置网页作者,例如可以为网站增加作者信息:</p><pre class="prism-highlight prism-language-bash" class='syl-page-code'><code><meta name='author' /></code></pre><p data-track='19'>其中name属性的值为author,用于定义搜索内容名称为网页作者,content属性的值用于定义具体的作者信息。</p><p data-track='20'>2)<meta http-equiv='名称' /></p><p data-track='21'>在<meta />标签中使用http-equiv和content属性可以设置服务器发送给浏览器的HTTP头部信息,为浏览器显示该页面提供相关的参数标准。其中,http-equiv属性提供参数类型,content属性提供对应的参数值。默认会发送<meta http-equiv='Content-Type' />,通知浏览器发送的文件类型是HTML。具体应用如下:</p><p data-track='22'>●设置字符集,例如某图片官网字符集的设置:</p><pre class="prism-highlight prism-language-bash" class='syl-page-code'><code><meta http-equiv='Content-Type' /></code></pre><p data-track='24'>其中http-equiv属性的值为Content-Type,content属性的值为text/html和charset=gbk,两个属性值中间用“;”隔开。这段代码用于说明当前文档类型为HTML,字符集为gbk(中文编码)。目前最常用的国际化字符集编码格式是utf-8,常用的国内中文字符集编码格式主要是gbk和gb2312。当用户使用的字符集编码不匹配当前浏览器时,网页内容就会出现乱码。<br>值得一提的是,在HTML5中,简化了字符集的写法,变为如下所示代码。</p><pre class="prism-highlight prism-language-bash" class='syl-page-code'><code><meta></code></pre><p data-track='26'>●设置页面自动刷新与跳转,例如定义某个页面10秒后跳转至百度:</p><pre class="prism-highlight prism-language-bash" class='syl-page-code'><code><meta http-equiv='refresh' /></code></pre><p data-track='28'>其中http-equiv属性的值为refresh,content属性的值为数值和url地址,中间用“;”隔开,用于指定在特定的时间后跳转至目标页面,该时间默认以秒为单位。</p> <div class="info-share-box clearfix"> <div class="fl"> <p class="tags"><strong>Tags:</strong><a href="http://www.nanyuegpt.com/tags-988.html" title="查看更多有关于“html5新增标签有哪些”的内容" rel="tag" target="_blank">html5新增标签有哪些</a></p> </div> <div class="fr"> <div class="info-share"> <div class="social-share" data-initialized="true"> <a href="#" class="social-share-icon iconfont icon-weibo"></a> <a href="#" class="social-share-icon iconfont icon-qq"></a> <a href="#" class="social-share-icon iconfont icon-wechat"></a> <a href="#" class="social-share-icon iconfont icon-qzone"></a> </div> </div> <script src="http://www.nanyuegpt.com/zb_users/theme/txcms2/script/social-share.min.js"></script> </div> </div> </div> <div class="sx mb15"> <ul> <li class="fl">上一篇: <a href="http://www.nanyuegpt.com/post/25255.html" title="HTML5 零基础完全教程-2-HTML5 基础标签">HTML5 零基础完全教程-2-HTML5 基础标签</a> </li> <li class="fr ziyou">下一篇: <a href="http://www.nanyuegpt.com/post/25257.html" title="HTML5教程从入门到精通,随堂笔记(二)H5的form标签">HTML5教程从入门到精通,随堂笔记(二)H5的form标签</a> </li> <div class="clear"></div> </ul> </div> <div class="xg"> <h2 class="ybbt">猜你喜欢</h2> <ul> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25266.html" title="HTML5中video标签如何使用(html中video标签添加属性)">HTML5中video标签如何使用(html中video标签添加属性)</a></li> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25265.html" title="Web前端干货!30道Web前端面试题精选,你会几个?">Web前端干货!30道Web前端面试题精选,你会几个?</a></li> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25264.html" title="HTML5 header标签的定义与规定(html中header标签的作用)">HTML5 header标签的定义与规定(html中header标签的作用)</a></li> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25263.html" title="HTML面试题:HTML5 有哪些新特性(html5的八大特性)">HTML面试题:HTML5 有哪些新特性(html5的八大特性)</a></li> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25262.html" title="HTML5 零基础完全教程-7-HTML5 语义化标签">HTML5 零基础完全教程-7-HTML5 语义化标签</a></li> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25261.html" title="HTML5学习笔记三:HTML5语法规则(html5语言基础)">HTML5学习笔记三:HTML5语法规则(html5语言基础)</a></li> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25260.html" title="广州新嘉华学:html5中的nav、article等标签用处">广州新嘉华学:html5中的nav、article等标签用处</a></li> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25259.html" title="html5学得好不好,看掌握多少标签">html5学得好不好,看掌握多少标签</a></li> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25258.html" title="html5简介、选项输入框、表单元素分组、input新增属性及属性值">html5简介、选项输入框、表单元素分组、input新增属性及属性值</a></li> <li><span class="">2025-03-25</span><i class="fa fa-caret-right"></i> <a href="http://www.nanyuegpt.com/post/25257.html" title="HTML5教程从入门到精通,随堂笔记(二)H5的form标签">HTML5教程从入门到精通,随堂笔记(二)H5的form标签</a></li> </ul> </div> </div> </div> <div class="right fr sjwu"> <dl class="wupd"> <div class="notice"> <div class="tab-hd"> <ul class="tab-nav"> <li class="on"><a href="javascript:;">最新文章</a></li> <li><a href="javascript:;">热门文章</a></li> <li><a href="javascript:;" class="wux">推荐文章</a></li> </ul> </div> <div class="tab-bd"> <div class="tab-pal" style="display:block"> <ul> <li><span class="fr zuo10">03-30</span><a href="http://www.nanyuegpt.com/post/25466.html" title="学会IDEA REST Client后,postman就可以丢掉了..." target="_blank">学会IDEA REST Client后,postman就可以丢掉了...</a></li> <li><span class="fr zuo10">03-30</span><a href="http://www.nanyuegpt.com/post/25465.html" title="学习在Postman中发送POST请求的最佳实践" target="_blank">学习在Postman中发送POST请求的最佳实践</a></li> <li><span class="fr zuo10">03-30</span><a href="http://www.nanyuegpt.com/post/25464.html" title="IDEA中居然藏着一个跟Postman一样好用的插件" target="_blank">IDEA中居然藏着一个跟Postman一样好用的插件</a></li> <li><span class="fr zuo10">03-30</span><a href="http://www.nanyuegpt.com/post/25463.html" title="《5分钟Java》实现excel文件上传并解析" target="_blank">《5分钟Java》实现excel文件上传并解析</a></li> <li><span class="fr zuo10">03-30</span><a href="http://www.nanyuegpt.com/post/25462.html" title="不会接口测试?用Postman轻松入门(八下)——请求结果断言方法" target="_blank">不会接口测试?用Postman轻松入门(八下)——请求结果断言方法</a></li> <li><span class="fr zuo10">03-30</span><a href="http://www.nanyuegpt.com/post/25461.html" title="「Postman」测试(Tests)脚本编写和断言详解" target="_blank">「Postman」测试(Tests)脚本编写和断言详解</a></li> <li><span class="fr zuo10">03-30</span><a href="http://www.nanyuegpt.com/post/25460.html" title="Spring Boot对接twilio发送邮件信息" target="_blank">Spring Boot对接twilio发送邮件信息</a></li> <li><span class="fr zuo10">03-30</span><a href="http://www.nanyuegpt.com/post/25459.html" title="Crowd 批量添加用户(Postman 数据驱动)" target="_blank">Crowd 批量添加用户(Postman 数据驱动)</a></li> </ul> </div> <div class="tab-pal"> <ul> <li><span class="fr zuo10">1455℃</span><a href="http://www.nanyuegpt.com/post/23583.html" title="桌面软件开发新体验!用 Blazor Hybrid 打造简洁高效的视频处理工具" target="_blank">桌面软件开发新体验!用 Blazor Hybrid 打造简洁高效的视频处理工具</a></li> <li><span class="fr zuo10">467℃</span><a href="http://www.nanyuegpt.com/post/4.html" title="命令的用法(dmesg命令的用法)" target="_blank">命令的用法(dmesg命令的用法)</a></li> <li><span class="fr zuo10">461℃</span><a href="http://www.nanyuegpt.com/post/3.html" title="什么是cmd(什么是cmd环境)" target="_blank">什么是cmd(什么是cmd环境)</a></li> <li><span class="fr zuo10">455℃</span><a href="http://www.nanyuegpt.com/post/5.html" title="3种解决方案:如何彻底删除C盘的垃圾文件" target="_blank">3种解决方案:如何彻底删除C盘的垃圾文件</a></li> <li><span class="fr zuo10">426℃</span><a href="http://www.nanyuegpt.com/post/6.html" title="CMD命令之——越走越远的封(zhuang)神(bi)之路!" target="_blank">CMD命令之——越走越远的封(zhuang)神(bi)之路!</a></li> <li><span class="fr zuo10">355℃</span><a href="http://www.nanyuegpt.com/post/204.html" title="git常用命令总结(git常用命令详解)" target="_blank">git常用命令总结(git常用命令详解)</a></li> <li><span class="fr zuo10">353℃</span><a href="http://www.nanyuegpt.com/post/198.html" title="Git学习笔记 001 Git基础 part1(git自学)" target="_blank">Git学习笔记 001 Git基础 part1(git自学)</a></li> <li><span class="fr zuo10">341℃</span><a href="http://www.nanyuegpt.com/post/7.html" title="CAD常用基本操作(cad常用基本操作快捷键)" target="_blank">CAD常用基本操作(cad常用基本操作快捷键)</a></li> </ul> </div> <div class="tab-pal"> <ul> </ul> </div> </div> </div> </dl> <dl class="function" id="divPrevious"> <dt class="function_t">最近发表</dt><dd class="function_c"> <ul><li><a title="学会IDEA REST Client后,postman就可以丢掉了..." href="http://www.nanyuegpt.com/post/25466.html">学会IDEA REST Client后,postman就可以丢掉了...</a></li> <li><a title="学习在Postman中发送POST请求的最佳实践" href="http://www.nanyuegpt.com/post/25465.html">学习在Postman中发送POST请求的最佳实践</a></li> <li><a title="IDEA中居然藏着一个跟Postman一样好用的插件" href="http://www.nanyuegpt.com/post/25464.html">IDEA中居然藏着一个跟Postman一样好用的插件</a></li> <li><a title="《5分钟Java》实现excel文件上传并解析" href="http://www.nanyuegpt.com/post/25463.html">《5分钟Java》实现excel文件上传并解析</a></li> <li><a title="不会接口测试?用Postman轻松入门(八下)——请求结果断言方法" href="http://www.nanyuegpt.com/post/25462.html">不会接口测试?用Postman轻松入门(八下)——请求结果断言方法</a></li> <li><a title="「Postman」测试(Tests)脚本编写和断言详解" href="http://www.nanyuegpt.com/post/25461.html">「Postman」测试(Tests)脚本编写和断言详解</a></li> <li><a title="Spring Boot对接twilio发送邮件信息" href="http://www.nanyuegpt.com/post/25460.html">Spring Boot对接twilio发送邮件信息</a></li> <li><a title="Crowd 批量添加用户(Postman 数据驱动)" href="http://www.nanyuegpt.com/post/25459.html">Crowd 批量添加用户(Postman 数据驱动)</a></li> <li><a title="RPA028-调用飞书API发送文件(.netのc#)" href="http://www.nanyuegpt.com/post/25458.html">RPA028-调用飞书API发送文件(.netのc#)</a></li> <li><a title="使用Postman快速上手ONES OpenAPI" href="http://www.nanyuegpt.com/post/25457.html">使用Postman快速上手ONES OpenAPI</a></li> </ul> </dd> </dl> <dl class="function" id="divTags"> <dt class="function_t">标签列表</dt><dd class="function_c"> <ul><li><a title="cmd/c" href="http://www.nanyuegpt.com/tags-1.html">cmd/c<span class="tag-count"> (57)</span></a></li> <li><a title="c++中::是什么意思" href="http://www.nanyuegpt.com/tags-18.html">c++中::是什么意思<span class="tag-count"> (57)</span></a></li> <li><a title="sqlset" href="http://www.nanyuegpt.com/tags-40.html">sqlset<span class="tag-count"> (59)</span></a></li> <li><a title="ps可以打开pdf格式吗" href="http://www.nanyuegpt.com/tags-208.html">ps可以打开pdf格式吗<span class="tag-count"> (58)</span></a></li> <li><a title="phprequire_once" href="http://www.nanyuegpt.com/tags-212.html">phprequire_once<span class="tag-count"> (61)</span></a></li> <li><a title="localstorage.removeitem" href="http://www.nanyuegpt.com/tags-237.html">localstorage.removeitem<span class="tag-count"> (74)</span></a></li> <li><a title="routermode" href="http://www.nanyuegpt.com/tags-247.html">routermode<span class="tag-count"> (59)</span></a></li> <li><a title="vector线程安全吗" href="http://www.nanyuegpt.com/tags-252.html">vector线程安全吗<span class="tag-count"> (70)</span></a></li> <li><a title="&" href="http://www.nanyuegpt.com/tags-296.html">&<span class="tag-count"> (66)</span></a></li> <li><a title="java" href="http://www.nanyuegpt.com/tags-297.html">java<span class="tag-count"> (73)</span></a></li> <li><a title="org.redisson" href="http://www.nanyuegpt.com/tags-410.html">org.redisson<span class="tag-count"> (64)</span></a></li> <li><a title="log.warn" href="http://www.nanyuegpt.com/tags-419.html">log.warn<span class="tag-count"> (60)</span></a></li> <li><a title="cannotinstantiatethetype" href="http://www.nanyuegpt.com/tags-465.html">cannotinstantiatethetype<span class="tag-count"> (62)</span></a></li> <li><a title="js数组插入" href="http://www.nanyuegpt.com/tags-468.html">js数组插入<span class="tag-count"> (83)</span></a></li> <li><a title="resttemplateokhttp" href="http://www.nanyuegpt.com/tags-471.html">resttemplateokhttp<span class="tag-count"> (59)</span></a></li> <li><a title="gormwherein" href="http://www.nanyuegpt.com/tags-474.html">gormwherein<span class="tag-count"> (64)</span></a></li> <li><a title="linux删除一个文件夹" href="http://www.nanyuegpt.com/tags-484.html">linux删除一个文件夹<span class="tag-count"> (65)</span></a></li> <li><a title="mac安装java" href="http://www.nanyuegpt.com/tags-578.html">mac安装java<span class="tag-count"> (72)</span></a></li> <li><a title="reader.onload" href="http://www.nanyuegpt.com/tags-641.html">reader.onload<span class="tag-count"> (61)</span></a></li> <li><a title="outofmemoryerror是什么意思" href="http://www.nanyuegpt.com/tags-648.html">outofmemoryerror是什么意思<span class="tag-count"> (64)</span></a></li> <li><a title="flask文件上传" href="http://www.nanyuegpt.com/tags-657.html">flask文件上传<span class="tag-count"> (63)</span></a></li> <li><a title="eacces" href="http://www.nanyuegpt.com/tags-659.html">eacces<span class="tag-count"> (67)</span></a></li> <li><a title="查看mysql是否启动" href="http://www.nanyuegpt.com/tags-680.html">查看mysql是否启动<span class="tag-count"> (70)</span></a></li> <li><a title="java是值传递还是引用传递" href="http://www.nanyuegpt.com/tags-687.html">java是值传递还是引用传递<span class="tag-count"> (58)</span></a></li> <li><a title="无效的列索引" href="http://www.nanyuegpt.com/tags-711.html">无效的列索引<span class="tag-count"> (74)</span></a></li> </ul> </dd> </dl> </div> <div class="clear"></div> </div> <div class="footer"> <div class="zh"> </div> </div> <div class="fixed-right"> <a href="javascript:;" class="gotop bgb" title="回到顶部"><i class="fa fa-chevron-up"></i></a> </div> <script src="http://www.nanyuegpt.com/zb_users/theme/txcms2/script/txcstx.min.js?v=2024-09-18"></script> </body> </html><!--463.03 ms , 13 queries , 3504kb memory , 0 error-->