HTML 5: 根項目, 標題,中繼資料元素, 指令碼元素

來源:互聯網
上載者:User

標籤:onload   htm   應用   引擎   標籤   scope   type   blog   tor   

HTML 5: 根項目, 中繼資料元素, 指令碼元素

  • 根項目 - doctype, html
  • 中繼資料元素 - head, title, base, link, meta, style
  • 指令碼元素 - script, noscript

1、<!doctype html>,文件類型

2、<html lang="zh-CN">,文檔的根項目

3、 head - 頭容器。

head - 頭容器,可包含如下標籤: title, base, link, meta, style, script。其中必須要有 title 標籤。

4、<title>我是標題</title>

5、<base href="http://pic.cnblogs.com/avatar/" target="_blank" />,設定文檔的預設地址和連結的預設開啟檔案

6、<link rel="stylesheet" type="text/css" href="http://www.www.www/css.css" />,

link定義兩個檔案的聯絡,一般用於樣式表檔案的引入。

rel-指定文檔間的關係,對樣式表來說此屬性的值為stylesheet。link標籤必須要有rel屬性。

type-所接入的文檔的類型。

href-所接入的文檔的地址。

title-所接入的文檔的標題,對於樣式表來說,可以在meta裡指定預設的樣式表的title,從而只使用指定title的樣式表。

disabled,rellist(唯讀),media,hreflang,sizes(唯讀)

7、meta - 文檔相關的中繼資料

Meta標籤是HTML語言中HEAD區的一個輔助性標籤,它位於HTML文檔頭部的<head>標記 和<title>標記之間,它提供使用者不可見的資訊。META標籤有兩個重要的屬性:HTTP標題資訊(HTTP-EQUIV)和頁面描述資訊(name)。

name屬性是描述網頁的,對應於content(網頁內容),以便於搜尋引擎機器人尋找、分類,目前幾乎所有的搜尋引擎都使用網上機器人自動尋找meta值來給網頁分類。Meta標籤的name屬性文法格式:<meta name="參數" content="具體參數值">


meta - 文檔相關的中繼資料。可用屬性如下:name, http-equiv, content, charset
  ·  <meta name="keywords/Description/Generator/Author/application-name/"  content="">
    <meta http-equiv="content-language/content-type/default-style/refresh/Set-Cookie/Prama/Cache-Control/Expires/windows-Target/viewport" content="">
    <meta charset="">

<!--
http-equiv, content 組合的樣本如下(不全)
-->
<!--定義文檔內容的語言-->
<meta http-equiv="content-language" content="zh-CN" />
<!--定義文檔內容的類型-->
<meta http-equiv="content-type" content="text/html" />
<!--定義文檔所使用的樣式表的 title,從而在有多個樣式表的時候,只使用指定 title 的樣式表。本例中會強制只使用 title 為 css1 的樣式表-->
<meta http-equiv="default-style" content="css1" />
<!--文檔每 100 秒重新整理一次-->
<meta http-equiv="refresh" content="100" />
<!--設定 cookie-->
<meta http-equiv="set-cookie" content="author=webabcd;" />


<!--定義文檔的編碼類別型-->
<meta charset="utf-8">

8、style - 定義文檔的樣式資訊
style - 定義文檔的樣式資訊。可用屬性如下: disabled, media, type, scoped
scoped - bool 類型的屬性,如果為 true,則代表樣式只能應用到 style 元素的父元素及其子項目(對於 scoped 為 false 的 style 只能寫在 head 內)
9、script - 用於定義用戶端指令碼
script - 用於定義用戶端指令碼,可用屬性如下:src, async, defer, type, charset
type - 指令碼的 MIME 類型,此屬性必須要有
src - 外部指令碼的 url 地址,如果指定了 src,那麼 script 標籤必須是空的
charset - 指令碼的編碼類別型
defer - bool 類型。如果為 true 的話,則指令碼在頁面解析完後執行,即在 DOMContentLoaded 事件之前執行,會按照 script 在頁面的出現順序執行,不阻塞頁面解析(介面解析的過程中,並行下載指令碼)
async - bool 類型。如果為 true 的話,則在頁面解析的過程中會非同步下載指令碼,指令碼下載完馬上執行(肯定會在 window 的 onload 事件之前執行),不阻塞頁面解析(介面解析的過程中,並行下載指令碼)

引用兩段指令碼,無 async 時或 defer 時,必然先執行完 script1 後再執行 script2
如果被標記為 async,假設 script2 先下載完,script1 後下載完的話,那麼會先執行 script2, 再執行 script1

HTML 5: 根項目, 標題,中繼資料元素, 指令碼元素

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.