Latest web development tutorials

HTML style attribute

HTML Global Attributes HTML Global Attributes

Examples

Using the style attribute in an HTML document:

<H1 style = "color: blue; text-align: center"> This is a heading </ h1>
<P style = "color: green"> This is a paragraph. </ P>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support style attributes


Definition and Usage

style attribute specifies the element inline style (inline style).

style property will override any global style settings, such as the <style> tag style or in an external style sheet specified.


Differences between HTML 4.01 and HTML5

In HTML5, style attribute can be used with any HTML element (it will verify that any HTML element, but not necessarily useful).

In HTML 4.01, style attributes can not be used: <base>, <head>, <html>, <meta>, <param>, <script>, <style>, and <title>.


grammar

<Elementstyle = "style_definitions">

Property Value

value description
style_definitions One or more separated by semicolons CSS properties and values. (Example: style = "color: blue; text-align: center")


HTML Global Attributes HTML Global Attributes