English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The style global attribute includes CSS style declarations applied to the element. Note that styles are best defined in a separate file. The main purpose of this attribute and the <style> element is for quick decoration. For example, for testing purposes.
Usage Notes:This attribute should not be used to pass semantic information. Even if all styles are removed, the page should retain the correct semantics. It is usually not applied to hide irrelevant information; this should be done using the hidden attribute.
Using the style attribute in HTML documents:
<!doctype html> <html> <head> <meta charset="UTF-8"> <title>HTML style attribute usage (Basic Tutorial Website oldtoolbag.com)</title>/title> </head> <body> <h1 style="color:blue;text-align:center">This is a header</h/h1> <p style="color:green">This is a paragraph.</p>/p> </body> </html>Test it out ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the style attribute
The style attribute specifies the inline style of an element.
The style attribute overrides any styles set globally, such as styles specified in <style> tags or external style sheets.
In HTML5In HTML, the style attribute can be used on any HTML element (it will validate on any HTML element. However, it may not be useful).
In HTML 4.01In HTML, the style attribute cannot be used with <base>, <head>, <html>, <meta>, <param>, <script>, <style>, and <title>.
<element style="style_definitions">
Value | Description |
---|---|
style_definitions | One or more CSS properties and values separated by semicolons. (For example: style="color:blue;text-align:center) |