Loading

Inline CSS

  • It is a method of adding CSS (Cascading Style Sheets) directly to individual HTML elements using the style attribute.
  • By using inline CSS we can style a specific element right within the HTML tag. 
  • It takes precedence over external stylesheets and internal styles defined in the document's <head> section.

Syntax:

<element style="property: value;">
  • <element>: Indicates the HTML element.
  • property: CSS property you want to apply.
  • value: the value you want to assign to the property.

Key Point:

  • Inline styles are defined within the "style" attribute of the relevant element.
  • Inline CSS is best suited for small, isolated styling changes or for quick prototyping

Example:

<!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>

Output:

This is a heading

This is a paragraph.