Name
style — HTML 4.01 | HTML5
Synopsis
<style> . . . </style>
Inserts style information (commonly Cascading Style Sheets) into
the head
of a document.
Notes
In HTML5, the style
element
may be used in the content of the document.
Start/End Tags
Required/Required
Attributes
Internationalization, HTML5 Global Attributes
id="
text
"
XHTML and XHTML5. Assigns a unique identifying name to the element.
media="all|aural|braille|handheld|print|projection|screen|tty|tv"
Specifies the intended destination medium for the style information. It may be a single keyword or a comma-separated list. The default in the HTML 4.01 spec is
screen
. In HTML5, the default isall
.scoped
(scoped="scoped"
in XHTML5)HTML5 only. Applies the styles only to the local document tree (i.e., only the descendants of the parent of the
style
element).title="
text
"
Gives the embedded style sheet a title.
type="
content type
"
(text/css
)Required in HTML 4.01. Specifies the style sheet language. For Cascading Style Sheets (currently the only style type option), the value is
text/css
. In HTML5, thetype
attribute is optional if using CSS.xml:space="preserve"
XHTML only. Instructs XML processors to preserve the whitespace in the element.
Example
Note that the type
attribute
is optional in HTML5 when using CSS.
<head> <style type="text/css"> h1 {color: #666;} </style> <title>Scientific Presentation</title> </head>
Get HTML & XHTML Pocket Reference, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.