HTML style Attribute
HTML Standard Attributes
Definition and Usage
The style attribute specifies an inline style for the element.
The style attribute will override any style set globally (in the <style> tag
or in a linked stylesheet).
The class attribute is mostly used with CSS to style elements. It can also be
used with JavaScript (using the HTML DOM) to change the
HTML element with the specified class.
Syntax
<element style="style-data">
Some text or element</element>
OR
<element style="style-data" />
|
Parameter |
Description |
style_data |
Required. A single, or a series of CSS property and values
separated by semicolons. |
element |
Required. The HTML element using the style. The style attribute
can be used on almost all HTML elements.
Exceptions:
- base
- head
- html
- meta
- param
- script
- style
- title
|
Support
W3C: The "W3C" column indicates whether or not the
attribute is defined in the W3C HTML/XHTML recommendation.
Internet Explorer |
Firefox |
Opera |
Safari |
W3C |
YES |
YES |
YES |
YES |
YES |
Example
Source |
Output |
<p style="text-align:center;color:blue;">
Hello World</p>
<p style="color:#1E90FF">
An inline style example</p>
|
Hello World
An inline style example
|
Try-It-Yourself Demos
The style
attribute
How to use the style attribute.
HTML Standard Attributes
 |
|
Get Your Diploma!
W3Schools' Online Certification Program is the perfect solution for busy
professionals who need to balance work, family, and career building.
The HTML Certificate is for developers who want to document their knowledge of HTML, XHTML, and CSS.
The JavaScript Certificate is for developers who want to document their knowledge of JavaScript and the HTML DOM.
The XML Certificate is for developers who want to document their knowledge of XML, XML DOM and XSLT.
The ASP Certificate is for developers who want to document their knowledge of ASP, SQL, and ADO.
The PHP Certificate is for developers who want to document their knowledge of PHP and SQL (MySQL).
|
|