/    /  External CSS

External CSS

External CSS is used to apply CSS on different pages or all pages. All the CSS code in a CSS file. Its extension must be .css for example style.css.

It uses the <link> tag on every page and the <link> tag should be put inside the head section.

 

Example:

 

<head> 
<link rel="stylesheet" type="text/css" href="style.css"> 
</head>

 

style.css  :

 

body { 
  background-color: lightblue; 
} 
h1 { 
  color: navy; 
  margin-left: 20px; 
}

 

Index.html:

 

<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="style.css">
</head>
<body>

<h1>This is a heading</h1>
<p>This is a paragraph.</p>

</body>
</html>

 

OUTPUT:

 

How to Add CSS