
type属性指定 <style>标签的Internet媒体类型(以前称为MIME类型),type属性标识 <style>和 </ style>标签之间的内容。
在线示例
使用type属性指定<style>标签的媒体类型:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML style type 属性使用-大卫编程网(div.cn)</title>
<style type="text/css">
h1 {color:red;}
p {color:blue;}
</style>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>测试看看 ‹/›浏览器兼容性
IEFirefoxOperaChromeSafari
所有主流浏览器都支持 type 属性。
定义和用法
type属性指定<style>标记的Internet媒体类型(以前称为MIME类型)。
type属性标识<style>和</ style>标记之间的内容。
值“ text / css”表示内容是CSS。
HTML 4.01 与 HTML5之间的差异
在 HTML5 中, type 属性可省略。默认值为 "text/css"。
语法
<style type="MIME_type">
属性值
| 值 | 描述 | 
|---|---|
| MIME_type | 样式表的Internet媒体类型。 目前,唯一支持的值为“ text / css”。 查看完整标准 MIME 类型列表 IANA MIME 类型。 | 
