Skip to main content

Inline CSS

An inline style is used to apply a unique style to a single element.

To use an inline style, add the style attribute to the element. The attribute can hold any CSS property.

Tip: An inline style mixes content with presentation and loses many of the benefits of a style sheet. Use it sparingly.

Example

The styles are written in the style attribute of each element.

Prompt
An HTML page that uses inline CSS via the style attribute on individual elements. Make the <h1> blue and centered using its style attribute, and make a <p> red using its style attribute. No <style> block and no external file.
Output: complete HTML page