HTML Dog
Skip to navigation

HTML Tag: style

Applies styles, typically CSS, at a page-level (as opposed to linking to an external CSS file). Typically placed inside the head element.

Optional Attributes

Attribute Description Possible values
media Which media the styles are associated to. Media query, such as screen, print, or screen and max-width:640.
type The type of the linked resource. MIME type. Typically text/css (default).
scoped Applies styles only to the style element’s parent element. When absent, the style element should appear in the head element. None.
Global attributes

Example


<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>