style (attribute)
The style global attribute contains CSS styling declarations to be applied to the element. Note that it is recommended for styles to be defined in a separate file or files. This attribute and the <style> element have mainly the purpose of allowing for quick styling, for example for testing purposes.
Browser support
| Feature | Desktop | Mobile | ||||
|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Safari | Chrome Android | Safari iOS | |
| 1 | 12 | 1 | 1 | 18 | 1 | |
1+Supported (version) Not supported ※Has note Sub-feature descriptions sourced from MDN Web Docs (CC BY-SA 2.5)
Syntax
HTML
<p style="color: #c00; font-weight: bold; margin: 1rem 0;">
Text formatted with inline styles
</p> Live demo
Use cases
-
Using style (attribute)
The style global attribute contains CSS styling declarations to be applied to the element.
Cautions
- May not be supported in older browsers.
Accessibility
- Verify how this element is announced by screen readers.