HTML <link> media 屬性
實例
針對兩種不同的媒介類型(電腦螢幕和列印)的兩種不同的樣式表:
    <head>
<link rel="stylesheet" type="text/css" href="theme.css">
<link rel="stylesheet" type="text/css" href="print.css" media="print">
</head>
<link rel="stylesheet" type="text/css" href="theme.css">
<link rel="stylesheet" type="text/css" href="print.css" media="print">
</head>
流覽器支持





所有主流流覽器都支持 media 屬性。
定義和用法
media 屬性規定被鏈接文檔將顯示在什麼設備上。
該屬性通常與 CSS 樣式表一起使用,用於為不同的媒介類型規定不同的樣式。
media 屬性接受若干個值。
HTML 4.01 與 HTML5之間的差異
media 屬性現在支持更多的值。
語法
    <link media="value">
可能的運算符
| 值 | 描述 | 
|---|---|
| and | 規定一個 AND 運算符。 | 
| not | 規定一個 NOT 運算符。 | 
| , | 規定一個 OR 運算符。 | 
設備
| 值 | 描述 | 
|---|---|
| all | 默認。適用於所有設備。 | 
| aural | 語音合成器。 | 
| braille | 盲文回饋裝置。 | 
| handheld | 手持設備(小螢幕、有限帶寬)。 | 
| projection | 投影儀。 | 
| 列印預覽模式/列印頁面。 | |
| screen | 電腦螢幕。 | 
| tty | 電傳打字機以及類似的使用等寬字元網格的媒介。 | 
| tv | 電視機類型設備(低解析度、有限的滾屏能力)。 | 
值
| 值 | 描述 | 
|---|---|
| width | 規定目標顯示區域的寬度。 可使用 "min-" 和 "max-" 首碼。 例子:media="screen and (min-width:500px)" | 
| height | 規定目標顯示區域的高度。 可使用 "min-" 和 "max-" 首碼。 例子:media="screen and (max-height:700px)" | 
| device-width | 規定目標顯示器/紙張的寬度。 可使用 "min-" 和 "max-" 首碼。 例子:media="screen and (device-width:500px)" | 
| device-height | 規定目標顯示器/紙張的高度。 可使用 "min-" 和 "max-" 首碼。 例子:media="screen and (device-height:500px)" | 
| orientation | 規定目標顯示器/紙張的方向。 可能的值:"portrait" 或 "landscape"。 例子:media="all and (orientation: landscape)" | 
| aspect-ratio | 規定目標顯示區域的寬度/高度比。 可使用 "min-" 和 "max-" 首碼。 例子:media="screen and (aspect-ratio:16/9)" | 
| device-aspect-ratio | 規定目標顯示器/紙張的 device-width/device-height 比率。 可使用 "min-" 和 "max-" 首碼。 例子:media="screen and (aspect-ratio:16/9)" | 
| color | 規定目標顯示器的 bits/color。 可使用 "min-" 和 "max-" 首碼。 例子:media="screen and (color:3)" | 
| color-index | 規定目標顯示器可以處理的顏色數。 可使用 "min-" 和 "max-" 首碼。 例子:media="screen and (min-color-index:256)" | 
| monochrome | 規定單色幀緩衝中的 bits/pixel。 可使用 "min-" 和 "max-" 首碼。 例子:media="screen and (monochrome:2)" | 
| resolution | 規定目標顯示器/紙張的像素密度 (dpi 或 dpcm)。 可使用 "min-" 和 "max-" 首碼。 例子: media="print and (resolution:300dpi)" | 
| scan | 規定 tv 顯示器的掃描方式。 可能的值:"progressive" 和 "interlace"。 例子:media="tv and (scan:interlace)" | 
| grid | 規定輸出設備是否是網格或位圖。 可能的值:"1" 為網格,否則為 "0"。 例子:media="handheld and (grid:1)" | 
 HTML <link> 標籤
  HTML <link> 標籤
			