style
The style global attribute applies inline CSS declarations directly to a single element.
Syntax
style="prop: value;" Examples
<p style="color: rebeccapurple; font-size: 1.25rem;">Inline styled text</p>
<div style="--gap: 1rem; gap: var(--gap);"></div>
Output
Renders the paragraph in purple at 1.25rem and sets a custom property on the div.
Notes
Inline styles have very high specificity and override most stylesheet rules, so use sparingly. Useful for dynamic per-element values and setting CSS custom properties. Blocked by strict CSP without a hash/nonce in some configurations.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |