External CSS

With an external style sheet, we can the change the entire website formatting using including the single css file.

Each HTML page must include a reference to the external style sheet file using the <link> tag inside the head section.

Syntax for Include the External CSS File.

<link rel="stylesheet" href="mystyle.css" >

mystyle.css

body {
  background-color: aliceblue;
}

h1 {
  color: tomato;
  margin-left: 10px;
}

The Below Example show the using of external css using <link> tag and how external css working in HTML document.

Example :

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

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

</body>
</html>
body {
  background-color: aliceblue;
}

h1 {
  color: tomato;
  margin-left: 10px;
}
  Try it Yourself