Tutorials References Exercises Videos Menu
Create Website Get Certified Upgrade

HTML style Attribute


Definition and Usage

The style attribute specifies an inline style for an element.

The style attribute will override any style set globally, e.g. styles specified in the <style> tag or in an external style sheet.


Applies to

The style attribute is part of the Global Attributes, and can be used on any HTML element.

Element Attribute
All HTML elements style

Example

Use of the style attribute in an HTML document:

<h1 style="color:blue;text-align:center">This is a header</h1>
<p style="color:green">This is a paragraph.</p>
Try it Yourself »

Browser Support

Attribute
style Yes Yes Yes Yes Yes