bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths

Loading lesson path

Learn/CSS/CSS Foundations
CSS•CSS Foundations

How To Add Inline CSS

Inline CSS

An inline style may be used to apply a unique style for a single element.

To use inline styles, add the style attribute to the relevant element. The style attribute can contain any CSS property.

Example

Formatted code
  <!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;text-align:center;">This
  is a heading</h1>
<p style="color:red;">This is a paragraph.</p>

  </body>
</html>

Live preview

Tip

An inline style loses many of the advantages of a style sheet (by mixing content with presentation). Use this method sparingly.

Previous

How To Add Internal CSS

Next

Multiple Style Sheets & Cascading Order