Inline CSS

Inline CSS is used to apply a unique style for a single line or element.

For use the Inline style we add the style attribute to particular element and this style attribute contain any CSS property.

Syntax of Inline CSS :

<tag style="cssproperty1:value; cssproperty2:value;"> </tag>    

Example :

<!DOCTYPE html>
<html>
 <body>

  <h1 style="color:red;text-align:center;">This is a heading</h1>
  <p style="color:blue;">This is a paragraph.</p>

 </body>
</html>
  Try it Yourself

Disadvantages of Inline CSS

  • We cannot use quotations within inline CSS. If you use quotations the browser will interpret this as an end of your style value.
  • These styles cannot be reused anywhere else and it's only single html element based.
  • These types of styles are tough to be updated because they are not stored at a single place.
  • We can't use the pseudo-codes and pseudo-classes with inline CSS.
  • Inline CSS does not give browser cache advantages.