The Style Attribute

The style attribute is one of the most powerful attributes you have access to. The style attribute can be added to almost any tag, and has hundreds of potential values that allow you to quickly and efficiently change the styling of some content. The style attribute's value is a little more complicated than every other attribute's value. Lets look at an example of a style attribute applied to a paragraph tag.

(source)

Styling a Paragraph

<p style="color: red">
	This text will be red.
</p>

This will result in this:

(results)

Styling a Paragraph

This text will be red.

Note that you do not need to include the style attribute in the closing tag, </p>.

The style attribute's value is split into two parts:

<tagname style="property1: value1; property2: value2; ">
...(text or more tags go here)...
</tagname>

You can add as many properties to a style tag as you wish, and separate properties are divided by a semicolon (;). We are going to learn a number of different properties for the style tag, the first of which are the color and the background-color properties.