meta 標記用來描述文件本身的資訊,例如關鍵字、簡述、作者與字元集,主要作用是幫助搜尋引擎理解並索引你的頁面。它一律寫在 <head> 與 </head> 之間。
設定關鍵字,多個關鍵字之間可用逗號分隔:
<meta name="keywords" content="value">
設定頁面簡述:
<meta name="description" content="value">
設定作者:
<meta name="author" content="作者名">
設定字元集:
<meta http-equiv="content-type" content="text/html;charset=gb2312">
設定頁面定時跳轉(2 秒後前進到指定網址):
<meta http-equiv="refresh" content="2;URL=https://www.itcast.cn" />
可以簡單記成:name 用來描述「關於這份文件的資訊」,例如 keywords、description、author;http-equiv 則用來模擬 HTTP 標頭的行為,例如 content-type 與 refresh。兩者都搭配 content 屬性提供實際數值。