第 362 篇 · 第 14 卷 前端,沒有極限 2026 年 7 月 7 日 · 台北
ls -lt ./posts --since=2013 REC · node 362 · uplink

html

html meta基本語法

2013 年 08 月 22 日 · 2 分鐘閱讀 · By Wang Casper

傳說中meta只要能夠使用的好,可以帶來許多意想不到的效果,甚至是連用了都不知道有什麼功能...。

參考文章:http://www.cnblogs.com/sniper007/p/3258389.html

延伸閱讀:http://code.lancepollard.com/complete-list-of-html-meta-tags/

meta的組成

相傳meat的是分別由http-equivname而組成,以下就依據該網頁介紹各種用法。

1.name屬性

<meta name="參數" content="具體的參數值">

功能是描述網頁,對應的屬性為content,主要的屬性有以下參數。

a.Keywords(關鍵字)

描述網頁的關鍵字

<meta name="keywords" content="a day a share">

b.​​description(網站內容描述)

描述網站的內容

<meta name="description" content="利用純靜態網頁,來分享Web技術,並透過每日的分享,來逐步提升自己的能力。">

c.robots(機器人嚮導)

用來告訴機器人那些頁面需要索引,而那些不需要。

<meta name="robots" content="none">
//參數有all,none,index,noindex,follow,nofollow

d.author(作者)

怎麼看都知道是作者。

<meta name="author" content="Casper">

2.http-equiv屬性

name主要作為描述,http-equiv則會與瀏覽器產生作用。

a.Expires(期限)

設定網頁的到期時間,只要過期,就必須重新傳輸。

<meta http-equiv="expires" content="Fri, 12 Jan 2001 18:18:18 GMT">

​​b.Pragma(cache模式)

禁止使用cache。

<meta http-equiv="Pragma" content="no-cache">

c.Refresh(刷新)

重新整理,並導向目標頁面。

<meta http-equiv="Refresh" content="2;URL=http://ashareaday.wcc.tw">
//2秒後重新導向...

d.Set-Cookie(cookie設定)

如果網頁過期,cookie將被刪除。

<meta http-equiv="Set-Cookie" content="cookievalue=xxx; expires=Friday, 12-Jan-2001 18:18:18 GMT; path=/">

e.content-Type(顯示字編碼的設定)

就...設定編碼

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

f.Window-target(顯示窗口的設定)

強制頁面在當前窗口以獨立頁面顯示。(這段不是很了解,似乎是不能被當成iframe?)

<meta http-equiv="Window-target" content="_top">

在html5之後meta屬性越來越多樣,還有許多目前沒提到,之後會依序補充。