
常用的 MIME 型態如下表
| Adobe Flash | application/x-shockwave-flash |
| Atom feeds | application/atom+xml |
| CSS | text/css |
| DTD | application/xml-dtd |
| ECMAScript/JavaScript | application/ecmascript, application/javascript |
| GIF | image/gif |
| GoogleWebToolkit data | text/x-gwt-rpc |
| Gzip | application/x-gzip |
| HTML | text/html |
| ICO | image/vnd.microsoft.icon |
| JPEG | image/jpeg, image/pjpeg |
| jQuery template data | text/x-jquery-tmpl |
| LaTeX | application/x-latex |
| MP3, MPEG | audio/mpeg |
| MP4 | audio/mp4 |
| Ogg | application/ogg |
| application/pdf | |
| PNG | image/png |
| PostScript | application/postscript |
| QuickTime | video/quicktime |
| RAR | application/x-rar-compressed |
| RealAudio | audio/vnd.rn-realaudio |
| RSS feeds | application/rss+xml |
| SVG | image/svg+xml |
| Textual data | text/plain |
| TIFF | image/tiff |
| WAV | audio/vnd.wave |
| WebM | audio/webm |
| Web Open Font Format | application/font-woff |
| Windows Media Audio | audio/x-ms-wma, audio/x-ms-wax |
| Windows Media Video | video/x-ms-wmv |
| XHTML | application/xhtml+xml |
| XML | text/xml |
| ZIP | application/zip |
通常內嵌元素 (embedded content) 如 <object> 、 <embed> 需要設定 type 屬性 (attribute) ,該屬性值必須是有效的 MIME 型態,一旦設定 type 就得與指定來源檔案的 src 屬性相符,不然有可能導致瀏覽器 (broswer) 無法處理,例如
<!DOCTYPE html>
<html>
<head>
<title>HTML 5 DEMO</title>
<style>
article {
display: block;
}
</style>
</head>
<body>
<section>
<article>
<embed type="text/plain" src="example.jpg">
</article>
</section>
</body>
</html>
<!-- 《程式語言教學誌》的範例程式
http://pydoing.blogspot.com/
檔名:mimetest.html
功能:示範 HTML 5 標記語言
作者:張凱慶
時間:西元 2011 年 12 月 -->Firefox 開啟如下

由於 <embed> 的 type 設定成 text/plain , src 卻是 example.jpg ,因此造成瀏覽器無法處理。
這裡須留意,如果沒有設定 type 屬性,瀏覽器大多會主動依 src 的來源檔案進行處理,有些媒體格式則一定得設定 type ,否則瀏覽器無法處理,因此最好認識網頁所需處理的媒體檔案是屬於哪種 MIME 型態,並且適當的設定 type 屬性。
| 中英文術語對照 | |
|---|---|
| 元素 | element |
| 內嵌元素 | embedded content |
| 屬性 | attribute |
| 瀏覽器 | broswer |
您可以繼續參考
基本概念
相關目錄
HTML 5 快速導覽
HTML, CSS 教材
首頁
參考資料
http://www.whatwg.org/specs/web-apps/current-work/multipage/the-video-element.html#mime-types
http://www.w3.org/TR/html5/video.html#mime-types
http://en.wikipedia.org/wiki/MIME
http://en.wikipedia.org/wiki/Internet_media_type
沒有留言:
張貼留言