XHTML » XHTML Core Tag » style


The style attribute is used to assign style sheet properties to the specific element containing the attribute.

Do not confuse this attribute with the style tag which 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 attribute behaves similarly to an inline style rule and only effects a small portion the HTML document.
There are four attributes common to most tags: class, id, style, and title.


<?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 Attribute Example</title>
<span style="color: brown; font-size: 24px; font-family: times;">
When in the course of human events...
When in the course of human events...

In this example, the text enclosed by the span tags will be red, size 24px and in Times font.

Language(s): XHTML