XHTML » Tags » style

<style> ... </style>

The style tag is used to create document-level style sheet rules. It is referred to as document-level because the style rules will apply to the entire HTML page. In contrast, the style core attribute behaves as an inline style rule and only effects a small portion the HTML document.

The style tag must appear inside the head element. The code, contained between the opening and closing style tags, is not HTML, but is CSS (Cascading Style Sheets). For more information about style sheets, please click on the CSS2 link in the left menu frame under the Quick References heading.


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<title>DevGuru XHTML style Tag Example</title>

<style type="text/css">
q { font-face: arial; color: black; font-size: 18px }
pre { font-face: arial; color: red; font-size: 24px }
code { font-face: courier; color: blue; font-size: 36px }

<q>DevGuru is great!</q>
<br />
<pre>D e v G u r u i s g r e a t !</pre>
<br />
<code>DevGuru is great!</code>
DevGuru is great!
D e v G u r u     i s     g r e a t !

DevGuru is great!

Here is a simple example of creating document-level style rules. A series of CSS properties defining font face, color, and size is assigned to the q, pre, and code tags.

Language(s): XHTML

See Also: