HTML Dog
跳至导航

HTML 标签:style

在页面级别(而不是链接到外部 CSS 文件)应用样式,通常是 CSS。通常放在 head 元素内。

可选属性

属性 描述 可能的值
media 样式关联到的媒体。 媒体查询,例如 screenprintscreen and max-width:640
type 链接资源的类型。 MIME 类型。通常是 text/css(默认)。
scoped 仅将样式应用于 style 元素的父元素。如果不存在,style 元素应出现在 head 元素中。 无。
全局属性

示例


<head lang="en">
    <style>
        /* Here be CSS for UHVerything */
    </style>
    <style media="print">
        /* Here be CSS applied exclusively when the page is printed */
    </style>
</head>

<body>

<!-- blah -->

<div>
    <style scoped>
        /* Here be CSS applied exclusively to this element's parent */
    </style>
    <p>So this element, and everything in its parent div, will get special treatment.</p>
</div>