HTML XHTML The Complete Reference
home » reference » appendix a » html element reference

<style> (Style Information)

This element is used to surround style sheet rules for a document. This element should be found only in the head element. Style rules within a document's <body> should be set with the style attribute for a particular element.

Standard Syntax

dir="ltr | rtl"
id="unique alphanumeric string"
lang="language code"
media="all | print | screen | others"
title="advisory text"
type="MIME Type"
CSS properties

Common Attributes

disabled="disabled" (DOM Level 1)

Events Introduced by Internet Explorer

onerror, onreadystatechange

Element Specific Attributes

This Microsoft-defined attribute is used to disable a style sheet. The presence of the attribute is all that is required to disable the style sheet. In conjunction with scripting, this attribute could be used to turn on and off various style sheets in a document.

This attribute specifies the destination medium for the style information. The value of the attribute can be a single media descriptor like screen or a comma-separated list. Possible values for this attribute include all, aural, braille, print, projection, screen, and tv. Other values also might be defined, depending on the browser. Internet Explorer supports all, print, and screen as values for this attribute.

This attribute is used to define the type of style sheet. The value of the attribute should be the MIME type of the style sheet language used. The most common current value for this attribute is text/css, which indicates a Cascading Style Sheet format.

This attribute is included from XHTML 1.0 and is used to specify whether spaces need to be preserved within the script element or whether the default white space handling should be employed. In practice, this attribute is not used by developers.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"">
<html xmlns="">
Style Sheet Example</title>

<style type="text/css">

  body  {background: black; color: white;
    font: 12pt Helvetica}
  h1    {color: red; font: 14pt Impact}



<h1>A 14-point red Impact heading on a black

Regular body text, which is 12 point white Helvetica



HTML 4, 4.01, XHTML 1.0, 1.1
Netscape 4, 4.5-4.8, 6, 7
Internet Explorer 3, 4, 5, 5.5, 6
Opera 4-7


Style information also can be specified in external style sheets as defined by the <link> tag.

Style information can also be associated with a particular element using the style attribute.

Style rules are often commented out within a <style> tag to avoid interpretation by nonconforming browsers.
<style type="text/css">
   body {background-color: red;

(X)HTML Elements
CSS Properties
Previous: strong Next: sub
< Home | About | Chapters | Examples | Errata | Reference | Site Map >