1. 程式人生 > >meta標籤的使用——使頁面適應各種裝置

meta標籤的使用——使頁面適應各種裝置

為了是頁面能適應移動端,一般會加上如下程式碼:

<meta name="viewport" content="width=device-width, initial-scale=1.0,minimum-scale=1.0" charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

那麼其意義究竟是什麼呢:

What does <meta http-equiv=“X-UA-Compatible” content=“IE=edge”> do?

寫給對<meta content="IE=edge,chrome=1" http-equiv="X-UA-Compatible">迷惑不解的小夥伴

meta name="viewport" content="width=device-width,initial-scale=1.0" 解釋

 

以下程式碼可加可不加:

<meta http-equiv="content-type" content="text/html; charset=UTF-8">

原因:

  • HTML 4.01: <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  • HTML5: <meta charset="UTF-8">