HTML » HTML Core Attributes » style

Version: 4.0

Syntax:
style="stylecode"

The style core attribute is used to create an inline set of style rules that define the appearance and presentation of text and images for a specific element. This is a convenient method for applying the effects of Cascading Style Sheets to a select portion of an entire HTML document. As a consequence, this core attribute is extremely useful.

Do not confuse this attribute with the style tag which is placed in the head of an HTML document and can be used to assign a set of style rules that affect the entire page or any portion.

Examples

Code:
<span style="color: orange;">DevGuru</span> products are great!
Output:
DevGuru products are great!
Explanation:

In this examples, an inline style script is first used to set the color of the word DevGuru.

Language(s): HTML
Code:
<span style="font-size: 2px;">a</span>
<span style="font-size: 4px;">a</span>
<span style="font-size: 6px;">a</span>
<span style="font-size: 8px;">a</span>
<span style="font-size:10px;">a</span>
<span style="font-size:12px;">a</span>
<span style="font-size:14px;">a</span>
<span style="font-size:16px;">a</span>
<span style="font-size:18px;">a</span>
<span style="font-size:20px;">a</span>
<span style="font-size:22px;">a</span>
<span style="font-size:24px;">a</span>
<span style="font-size:26px;">a</span>
<span style="font-size:28px;">a</span>
<span style="font-size:30px;">a</span>
<span style="font-size:32px;">a</span>
<span style="font-size:34px;">a</span>
Output:
a a a a a a a a a a a a a a a a a
Explanation:

This example uses the span tag to grow the size of the letter a.

Language(s): HTML