This page is Ready to Use

Notice: The WebPlatform project has been discontinued when the Stewards partnership agreement ended in September 2015. This site has been frozen, and the assets we have created will remain.



Sets an inline style for the element.

Applies to dom/HTMLElement
This attribute is used to set styling in the form of [CSS rules](/guides/getting_started_with_css#Defining_style_rules) to an element.


<!doctype html>
<title>HTML Style Attribute Usage</title>
<p style="background-color: blue; color: white;">This will be white text with a blue background.</p>

View live example


 While this is perfectly valid, it is *highly* recommended by the community at large that you not use inline styles. Instead it is much better to simply target the element you want in your CSS and apply rules in there.



This attribute is not accessible through scripting. To access styles through scripting, use the style object.

Related specifications

HTML4 Specification
W3C Recommendation