理筋一手堂 發表於 2019-9-8 14:02:00

HTML5基础知识汇总(一)

<h2><span style="color: rgba(51, 102, 255, 1)">一、HTML的开发工具和使用的浏览器</span></h2>
<p><span style="font-size: 16px">开发工具:记事本等文本编辑器,Atom、VisualStudioCode( VSCode)、Brackets、Sublime text和Hbuider。</span></p>
<p><span style="font-size: 16px">浏览器:Chrome、Firefox、IE、Safari、IPhone、Android。</span></p>
<p>&nbsp;</p>
<hr>
<p>&nbsp;</p>
<h2><span style="color: rgba(51, 102, 255, 1)">二、HTML的基本要素</span></h2>
<p><span style="font-size: 16px"><span style="background-color: rgba(204, 255, 255, 1)">DOCTYPE</span>&nbsp; 描述文档的类型</span></p>
<p><span style="font-size: 16px"><span style="background-color: rgba(204, 255, 255, 1)">html</span>&nbsp; &nbsp; &nbsp;网页的根元素,写在网页的在外面</span></p>
<p><span style="font-size: 16px"><span style="background-color: rgba(204, 255, 255, 1)">head&nbsp;</span> &nbsp; 网页的头部信息,写在html标记的里面</span></p>
<p><span style="font-size: 16px"><span style="background-color: rgba(204, 255, 255, 1)">body</span>&nbsp; &nbsp; 网页的内容,写在html标记的里面</span></p>
<p><span style="font-size: 16px; background-color: rgba(255, 255, 153, 1)"><strong>具体描述:</strong></span></p>
<p><span style="font-size: 16px">1、<span style="background-color: rgba(255, 255, 153, 1)">DOCTYPE</span>&nbsp; 描述文档的类型,规定web 浏览器关于页面使用哪个 HTML 版本进行编写的指令。</span></p>
<p><span style="font-size: 16px">网页可以使用的具体版本,网页中可以使用那些标记,每个版本的DTD版本均有不同</span></p>
<p><span style="font-size: 16px; background-color: rgba(255, 153, 204, 1)">使用例子</span></p>
<p><span style="font-size: 16px">HTML4的例子</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;!</span><span style="color: rgba(255, 0, 255, 1)">DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p><span style="font-size: 16px">HTML5的例子</span></p>
<p><span style="font-size: 16px"><img src="https://img2018.cnblogs.com/blog/1748092/201909/1748092-20190908135416257-1792718590.png" alt=""></span></p>
<p><strong><span style="font-size: 16px">2、<span style="background-color: rgba(255, 255, 153, 1)">&lt;html&gt;&lt;/html&gt;</span> 网页文档中的根标记</span></strong></p>
<p><span style="font-size: 16px">html 标签有三个特殊的属性  </span></p>
<ul>
<li><span style="font-size: 16px">manifest&nbsp; &nbsp;指定网页缓存文件,可以让用户离线的时候也可以访问文件。</span></li>
<li><span style="font-size: 16px">xmlns&nbsp; &nbsp;设置html名空间,比如把网页设置成xhml的时候可以使用这个值。</span></li>
<li><span style="font-size: 16px">lang&nbsp; &nbsp;设置网页的描述语言,比如中文是zh;英文是en。</span></li>
</ul>
<p><span style="font-size: 16px"><strong>3、<span style="background-color: rgba(255, 255, 153, 1)">&lt;head&gt;&lt;/head&gt;</span></strong>头部标签在网页中只能有一个,设置HTML文档的头部信息,里面内容不会在页面中显示出来·。</span></p>
<p><span style="font-size: 16px">head里面的标记</span></p>
<ul>
<li><span style="font-size: 16px">&lt;meta&gt; 标记</span></li>
<li><span style="font-size: 16px">&lt;title&gt;定义网页的标题</span></li>
<li><span style="font-size: 16px">&lt;link&gt; 链接</span></li>
<li><span style="font-size: 16px">&lt;script&gt;&nbsp; 标记JavaScript脚本的内容</span></li>
<li><span style="font-size: 16px">&lt;style&gt;&nbsp; 标记css样式</span></li>
<li><span style="font-size: 16px">meta&nbsp; 标记</span></li>
</ul>
<p><span style="font-size: 16px"><strong>4、<span style="background-color: rgba(255, 255, 153, 1)">&lt;body&gt;&lt;/body&gt;</span></strong>只能有一个,显示网页的主体内容。</span></p>
<p><span style="font-size: 16px; background-color: rgba(255, 153, 204, 1)">代码示例:</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> <span style="color: rgba(0, 0, 255, 1)">&lt;!</span><span style="color: rgba(255, 0, 255, 1)">DOCTYPE html</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 2</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">html </span><span style="color: rgba(255, 0, 0, 1)">lang</span><span style="color: rgba(0, 0, 255, 1)">="en"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 3</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 4</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">charset</span><span style="color: rgba(0, 0, 255, 1)">="UTF-8"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 5</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>网页标题(显示在浏览器上)<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 6</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="description"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="网页内容的简单描述"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 7</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="keywords"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="网页关键词"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 8</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="/css/style.css"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 9</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">script </span><span style="color: rgba(255, 0, 0, 1)">src</span><span style="color: rgba(0, 0, 255, 1)">="/js/script.js"</span><span style="color: rgba(0, 0, 255, 1)">&gt;&lt;/</span><span style="color: rgba(128, 0, 0, 1)">script</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">10</span> <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">11</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">body</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">12</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">header</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>网页头部内容<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">header</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">13</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">main</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>网页主要内容<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">main</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">14</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">nav</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>网页的导航内容<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">nav</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">15</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">footer</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>网页的页脚内容<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">footer</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">16</span> <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">body</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">17</span> <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">html</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p><img src="https://img2018.cnblogs.com/blog/1748092/201909/1748092-20190908094145359-1796972756.png" alt=""></p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<hr>
<p>&nbsp;</p>
<h2><span style="color: rgba(51, 102, 255, 1)">三、写在&lt;head&gt;中的标签</span></h2>
<h2><span style="background-color: rgba(255, 255, 153, 1)">(一)、&lt;meta&gt;标签</span></h2>
<p><strong><span style="font-size: 16px">&lt;meta&gt;元素的属性:</span></strong></p>
<ul>
<li><span style="font-size: 16px"><strong>name</strong> 描述信息的名称,来标记这是一个什么样的信息</span></li>
<li><span style="font-size: 16px"><strong>http-equiv</strong>&nbsp; 描述行为</span></li>
<li><span style="font-size: 16px"><strong>content</strong>&nbsp; 描述的内容</span></li>
<li><span style="font-size: 16px"><strong>charset</strong>&nbsp; &nbsp;指定网页的编码</span></li>
</ul>
<p><span style="text-decoration: underline"><span style="font-size: 16px"><strong>1、name 属性</strong></span></span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="author"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="nyw"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">2</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)">作者, 定义网页的作者 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">3</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="description"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="meta标记学习"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">4</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 描述,描述网页的实际内容 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">5</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="keywords"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="HTML,meta"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">6</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 关键字,定义网页关键字 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span></pre>
</div>
<p><span style="text-decoration: underline"><span style="font-size: 16px"><strong>2、http-equiv属性</strong></span></span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">http-equiv</span><span style="color: rgba(0, 0, 255, 1)">="refresh"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="30"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">2</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 网页30s后自动刷新 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">3</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">http-equiv</span><span style="color: rgba(0, 0, 255, 1)">="refresh"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="5,url=dom.html"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">4</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 网页30秒后跳转到dom.html文档 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span></pre>
</div>
<p><span style="font-size: 16px"><strong>&lt;meta http-equiv="refresh" content="5,url=dom.html"&gt;</strong></span></p>
<p><span style="font-size: 16px">http-equiv描述网页的行为,行为 refresh刷新,内容为5,表示5秒后跳转到 dom.html这个文档。</span></p>
<p><span style="text-decoration: underline"><span style="font-size: 16px"><strong>3、content 属性</strong></span></span></p>
<p><span style="font-size: 16px">特殊属性</span></p>
<ul>
<li><span style="font-size: 16px"><strong>content-type&nbsp;</strong> &nbsp;指定http头部信息的文字编码(最为常用)</span></li>
<li><span style="font-size: 16px"><strong>default-style</strong>&nbsp; &nbsp;指定优先使用的样式单(stylesheet)</span></li>
<li><span style="font-size: 16px"><strong>refresh</strong>&nbsp; &nbsp; 用于网页的自动刷新或是页面跳转</span></li>
<li><span style="font-size: 16px"><strong>set-cookie&nbsp;</strong> &nbsp;设置页面的cookie(现在已经不再推荐使用)</span></li>
</ul>
<p><span style="text-decoration: underline"><strong><span style="font-size: 16px">4、charset属性</span></strong></span></p>
<p><span style="font-size: 16px">指定网页的编码,推荐使用UTF-8来增加网页的兼容性。</span></p>
<p><span style="color: rgba(255, 153, 204, 1); font-size: 16px"><strong>代码实例:</strong></span></p>
<p><span style="font-size: 16px">为搜索引擎抓取机器人准备一些信息</span></p>
<p><span style="font-size: 16px">这段代码可以禁止搜索引擎缓存和跟踪网页。</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="robots"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="noindex,nofollow"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> name定义的是机器人,内容部分表示不要被搜索引擎缓存,也不要被搜索引擎跟踪 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span></pre>
</div>
<p><span style="font-size: 16px; background-color: rgba(255, 153, 204, 1)">代码实例:</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)"> 1</span> <span style="color: rgba(0, 0, 255, 1)">&lt;!</span><span style="color: rgba(255, 0, 255, 1)">DOCTYPE html</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 2</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">html </span><span style="color: rgba(255, 0, 0, 1)">lang</span><span style="color: rgba(0, 0, 255, 1)">="en"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 3</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 4</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">charset</span><span style="color: rgba(0, 0, 255, 1)">="UTF-8"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 5</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>网页标题(显示在浏览器上)<span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">title</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 6</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="author"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="nyw"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 7</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)">作者, 定义网页的作者 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 8</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="description"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="meta标记学习"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)"> 9</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 描述,描述网页的实际内容 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">10</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="keywords"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="HTML,meta"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">11</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 关键字,定义网页关键字 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">12</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">http-equiv</span><span style="color: rgba(0, 0, 255, 1)">="refresh"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="30"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">13</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 网页30s后自动刷新 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">14</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">http-equiv</span><span style="color: rgba(0, 0, 255, 1)">="refresh"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="5,url=dom.html"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">15</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 网页30秒后跳转到dom.html文档 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">16</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">meta </span><span style="color: rgba(255, 0, 0, 1)">name</span><span style="color: rgba(0, 0, 255, 1)">="robots"</span><span style="color: rgba(255, 0, 0, 1)"> content</span><span style="color: rgba(0, 0, 255, 1)">="noindex,nofollow"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">17</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> name定义的是机器人,内容部分表示不要被搜索引擎缓存,也不要被搜索引擎跟踪 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">18</span> <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">head</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">19</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">body</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">20</span> <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">body</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">21</span> <span style="color: rgba(0, 0, 255, 1)">&lt;/</span><span style="color: rgba(128, 0, 0, 1)">html</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<h2><span style="background-color: rgba(255, 255, 153, 1)">(二)、title、base标记</span></h2>
<p><span style="font-size: 16px">title和base标记都是写在head标签中</span></p>
<p><span style="text-decoration: underline"><span style="font-size: 16px"><strong>title:设置网页的标题</strong></span></span></p>
<p><span style="font-size: 16px"><strong>写法:</strong>&lt;title&gt;内容&lt;/title&gt;。</span></p>
<p><span style="text-decoration: underline"><span style="font-size: 16px"><strong>base:指定网页跳转基准URL,如果不指定的话默认为当前网站的当前路径。</strong></span></span></p>
<p><span style="font-size: 16px"><strong>写法:</strong>&lt;base href="http://www.aaa.zzz/"&gt;</span></p>
<p><span style="font-size: 16px"><strong>base属性值:</strong></span></p>
<ul>
<li><span style="font-size: 16px">href&nbsp; 指定网页跳转到基准URL,如果不指定的话则默认为当前网站的当前路径。</span></li>
</ul>
<p><span style="font-size: 16px">&lt;base href="http://baidu.com/"&gt;&nbsp;&nbsp;这是将页面跳转到百度的网站打开。</span></p>
<ul>
<li><span style="font-size: 16px">target&nbsp; 指定链接的跳转帧如果不指定的话,则是在当前页面中跳转。</span></li>
</ul>
<p><span style="font-size: 16px">&lt;base target="_blank"&gt;&nbsp;网页中的链接都应该在新的窗口中打开。</span></p>
<p><span style="font-size: 16px"><strong>terget属性值:</strong></span></p>
<ul>
<li><span style="font-size: 16px">_blank&nbsp; 在新窗口中打开被链接的文档</span></li>
<li><span style="font-size: 16px">_self&nbsp; &nbsp;默认值,在相同框架中打开被链接的文档</span></li>
<li><span style="font-size: 16px">_parent&nbsp; &nbsp;在父框架集中</span></li>
<li><span style="font-size: 16px">_top&nbsp; &nbsp;在整个窗口中打开被链接文档·</span></li>
<li><span style="font-size: 16px">framename&nbsp; &nbsp;在指定框架中打开被链接文档</span></li>
</ul>
<h2><span style="background-color: rgba(255, 255, 153, 1)">(三)、link标记</span></h2>
<p><span style="font-size: 16px"><strong>link标记:链接外部文件时使用的标记,可以把外部文件的内容引入到当前文件中来,使当前网页实现更多的功能。</strong></span></p>
<p><span style="font-size: 16px"><strong>link属性:</strong></span></p>
<p><span style="font-size: 16px">href:指定链接外部路径的路径和文件名,要设置全路径并且带文件名</span></p>
<p><span style="font-size: 16px">rel:引用文件,引用资源的类型定义</span></p>
<p><span style="font-size: 16px">我们在使用link标签引用外部文件的时候,外部文件的类型是多种多样的。</span></p>
<p style="margin-left: 30px"><span style="font-size: 16px">alternate&nbsp; &nbsp;代替文档(种子,其他语言版本,其他格式等等)</span></p>
<p style="margin-left: 30px"><span style="font-size: 16px">author&nbsp; &nbsp;网页的作者</span></p>
<p style="margin-left: 30px"><span style="font-size: 16px">help&nbsp; 帮助文件的链接</span></p>
<p style="margin-left: 30px"><span style="font-size: 16px">icon&nbsp; 网页的图标</span></p>
<p style="margin-left: 30px"><span style="font-size: 16px">next&nbsp; 如果是连续网页的时候,指定下一个网页</span></p>
<p style="margin-left: 30px"><span style="font-size: 16px">prefetch&nbsp; &nbsp;把链接外部资源时提前缓存起来。</span></p>
<p style="margin-left: 30px"><span style="font-size: 16px">prev&nbsp; &nbsp;如果是连续网页</span></p>
<p><span style="font-size: 16px">media&nbsp; 链接文件或是资源属于哪一种资源。</span></p>
<p><span style="font-size: 16px">hreflang&nbsp; &nbsp;链接文件的语言种类</span></p>
<p><span style="font-size: 16px">type&nbsp; 链接文件的mi/me类型(比如说,图片图标文本)</span></p>
<p><span style="font-size: 16px">sizes&nbsp; 根据link链接文件的类型,来指定文件的大小</span></p>
<p><span style="font-size: 16px; background-color: rgba(255, 153, 204, 1)">代码示例:</span></p>
<p><strong><span style="font-size: 16px">链接网页图标:</span></strong></p>
<pre><span style="font-size: 16px">网站的图标指定,可以显示在浏览器的图标栏,也可以被手机读取作为网站的图标存入收藏夹</span></pre>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 网站的图标指定,可以显示在浏览器的图标栏,也可以被手机读取作为网站的图标存入收藏夹 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">2</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="icon"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">3</span>   <span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 示例 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">4</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="icon"</span><span style="color: rgba(255, 0, 0, 1)"> href</span><span style="color: rgba(0, 0, 255, 1)">="img/favicon.png"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="image/png"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">5</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="shortcut icon"</span><span style="color: rgba(255, 0, 0, 1)"> href</span><span style="color: rgba(0, 0, 255, 1)">="img/favicon.ico"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="image/x-icon"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">6</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="apple-touch-icon"</span><span style="color: rgba(255, 0, 0, 1)"> href</span><span style="color: rgba(0, 0, 255, 1)">="img/apple-touch-icon.png"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="image/png"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p><span style="font-size: 16px"><span style="color: rgba(255, 0, 0, 1)"><strong>注意:</strong></span>后面的href和前面type标注的类型要一致,这样既可以显示在浏览器,又可以显示在手机上</span></p>
<p><span style="font-size: 16px">链接外部样式单</span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 128, 1)">1</span> <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="stylesheet"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">2</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="stylesheet"</span><span style="color: rgba(255, 0, 0, 1)"> href</span><span style="color: rgba(0, 0, 255, 1)">="style1.css"</span><span style="color: rgba(255, 0, 0, 1)"> media</span><span style="color: rgba(0, 0, 255, 1)">="screen"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">3</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="stylesheet"</span><span style="color: rgba(255, 0, 0, 1)"> href</span><span style="color: rgba(0, 0, 255, 1)">="style2.css"</span><span style="color: rgba(255, 0, 0, 1)"> title</span><span style="color: rgba(0, 0, 255, 1)">="主题样式文件"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
<span style="color: rgba(0, 128, 128, 1)">4</span>   <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">=" alternate stylesheet"</span><span style="color: rgba(255, 0, 0, 1)"> href</span><span style="color: rgba(0, 0, 255, 1)">="style3.css"</span><span style="color: rgba(255, 0, 0, 1)"> title</span><span style="color: rgba(0, 0, 255, 1)">="可选样式单"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p><span style="font-size: 16px">说明:</span></p>
<p><span style="font-size: 16px">alternate 会在浏览器中会弹出一个对话框,供用户可以进行选择</span></p>
<p><span style="font-size: 16px">media&nbsp; 表示媒体类型为屏幕,可以是手机,但不包括打印机和投影仪</span></p>
<p><span style="font-size: 16px">title&nbsp; 对这个link进行简单的说明</span></p>
<p><strong><span style="font-size: 16px">网站RSS种子指定</span></strong></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 网站RSS种子指定 </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="alternate"</span><span style="color: rgba(255, 0, 0, 1)"> type</span><span style="color: rgba(0, 0, 255, 1)">="application/rss+xml"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p><span style="font-size: 16px"><strong>为搜索引擎的准备的网页的URL</strong></span></p>
<div class="cnblogs_code">
<pre><span style="color: rgba(0, 128, 0, 1)">&lt;!--</span><span style="color: rgba(0, 128, 0, 1)"> 为搜索引擎的准备的网页的URL </span><span style="color: rgba(0, 128, 0, 1)">--&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="canonical"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span>
    <span style="color: rgba(0, 0, 255, 1)">&lt;</span><span style="color: rgba(128, 0, 0, 1)">link </span><span style="color: rgba(255, 0, 0, 1)">rel</span><span style="color: rgba(0, 0, 255, 1)">="canonical"</span><span style="color: rgba(255, 0, 0, 1)"> href</span><span style="color: rgba(0, 0, 255, 1)">="http://www.aaa.zzz/help.html"</span><span style="color: rgba(0, 0, 255, 1)">&gt;</span></pre>
</div>
<p><span style="font-size: 16px">告诉搜索引擎代替URL是哪里。</span></p><br><br>
来源:https://www.cnblogs.com/nyw1983/p/11485899.html
頁: [1]
查看完整版本: HTML5基础知识汇总(一)