Required | Tag Specific | Core | Focus | Events | Language |
---|---|---|---|---|---|
type | media xml:space1 | id1 title | dir lang xml:lang1 | ||
Notes: 1. XHTML only. |
Attribute | Description |
---|---|
type | The type attribute specifies the style sheet language. The value "text/css" can be used for Cascading Style Sheets (CSS). HTML <style> tag example using the type attribute. <html>
<head>
<title>HTML Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css">
p, h1, h2 {color: red;}
h3 {text-align: center;}
</style>
</head>
<body>
<h1>h1 tag color set to red.</h1>
<h2>h2 tag color set to red.</h2>
<h3>h3 tag text-align set to center.</h3>
<p>p tag color set to red.</p>
</body>
</html> XHTML <style> tag example using the type attribute. <html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>HTML Test</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
p, h1, h2 {color: red;}
h3 {text-align: center;}
</style>
</head>
<body>
<h1>h1 tag color set to red.</h1>
<h2>h2 tag color set to red.</h2>
<h3>h3 tag text-align set to center.</h3>
<p>p tag color set to red.</p>
</body>
</html> Note: This is a required attribute. |
media | The media attribute is used to specify the target medium for the style information. Possible values include "all", "aural", "braille", "handheld", "print", "projection", "screen", "tty", "tv". More than one value can be specified by separating them with commas. The following example specifies a style to be used when the document is printed: <style type="text/css" media="print"> |
xml:space | The xml:space attribute is used to specify that whitespace should be preserved. XHTML <style> tag example: <style type="text/css" xml:space="preserve"> Note: XHTML only. |
id | The id attribute assigns a unique name to a tag. This allows style sheets or scripts to reference the tag. See id Example Note: XHTML only. |
title | The title attribute specifies additional information about the tag. It is common for browsers to display the title when the pointing device stops over the object. See title Example |
dir | The dir attribute tells the browser whether the text should be displayed from left-to-right or right-to-left. It does not reverse the direction of the characters, like the <bdo> tag does, but it can help the browser to determine if the text should be aligned on the left side or the right side. See dir Example |
lang | The lang attribute specifies a language. This attribute can help the browser to correctly display text. This attribute can also be useful for braille translation software, speech synthesizers, dictionary definitions, etc. See lang Example |
xml:lang | The xml:lang attribute specifies a language for XHTML documents. This attribute can help the browser to correctly display text. This attribute can also be useful for braille translation software, speech synthesizers, dictionary definitions, etc. See xml:lang Example Note: XHTML only. |
<style> tag example. |