Previous Next

Adding CSS

There are three methods to apply CSS to an HTML page:

Inline CSS

To apply inline CSS, place the style attribute in the first tag of an HTML element.

Example:

<h1 style="color: blue;"> Tutorials4Coding </h1> 
<p> Learn Coding easily! </p>

Output

Internal CSS

The internal style is declared inside the <style> tag of the head part.

Example:

<!DOCTYPE html>
<html>
<head>
  <style>
    h2 {
     color: red;
    }
  </style>
</head>
<body>
  <h2> Hello Coders! </h2>
  <p>Welcome to this css tutorial.</p>
</body>
</html>

Output

External CSS

External CSS is declared in another CSS file and referenced to the HTML page inside the <head> section using the <link> tag.

Example:

Previous Next