HTML style Attribute

HTML style Attribute: This attribute defines an inline style for an element. Styles in HTML are basically rules that describe how a document will be presented in a browser. Style information can be either attached as a separate document or embedded in the HTML document.

Inline Style

In Inline styling, the CSS rules are directly written inside the starting tag using the style attribute. The style attribute includes a series of CSS property and value pairs. Each ‘property: value ‘ pair is separated by a semicolon ( ; ).

HTML style Attribute

This attribute can be applied to all the HTML elements. There are 3 ways of implementing style in HTML :

Inline Style: In this method, the style attribute is used inside the HTML start tag.
Embedded Style: In this method, the style element is used inside the <head> element of the document.
External Style Sheet: In this method, the <link> element is used to point to an external CSS file.

Browser Support

This attribute is supported by the following browsers:

  • Chrome
  • Firefox
  • Internet Explorer
  • Safari
  • Opera

Example: for a style attribute

<!DOCTYPE html>
<h1 style="color:orange;text-align:center">Header</h1>
<p style="color:green">Paragraph.</p>


HTML style attribute