Style - HTML Attribute
The style attribute is used for inline styling of elements, and little quick-fixes, but should be avoided otherwise.
Edited: 2017-12-11 04:54
The HTML style attribute is used to apply styling rules directly on elements, also known as inline styles. Its generally recommended to apply styles in external CSS files, since it will allow browsers to make use of caching, speeding up the page load times, and lowering the bandwidth usage both on the client, and the server side.
The style element can be used on all style-able elements. I.e.
<p style="color:black;margin: 1em 0 2em;">Test paragraph</p>
If you are using multiple CSS properties you should separate each property with a semicolon ";".
The style attribute will override styling globally. I.e. Styles set in external StyleSheets, and from style elements in the page.
When to use the Style Attribute
The style attribute can be used for quick fixes, and in situations where you don't have access to the CSS files, and still want to change the appearance of the elements on a page. It is, however, usually better to use external stylesheets.
It can also be useful to quickly test something directly on your site, especially if you do not have easy access to the CSS files, or if you are just to lazy to fire up your editor.
Tell us what you think: