class attribute
id attribute
style tag
span tag
ATTRIBUTE: style
style="string"
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
.
In this example, the text enclosed by the
span
tags will be brown, size 24px and in Times font.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
<head>
<title>DevGuru XHTML style Attribute Example</title>
</head>
<body>
<span
style="color: brown; font-size: 24px; font-family: times;"
>
When in the course of human events...
</span>
</body>
</html>
Output:
When in the course of human events...
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information