External CSS

When we use a separate file for page style (CSS) and add it to our HTML, it's called styling with an external CSS.

To use an external style sheet, add a link to it in the <head> section of the HTML page.

For example,


<head>
  <link rel="stylesheet" href="styles.css">
</head>

An external style sheet must not contain any HTML code, and must be saved with a .css extension.

For example:


body {
  background-color: green;
}

p {
  color: black;
}

Advantages

1. It helps you keep your website design and content separate.

2. An external style sheet is used to define the style for many HTML pages. 

3. It's really easy to reuse your CSS code if we have it in a separate file. Typing the same CSS style code in all pages you have is time consuming. Also, just imagine if you want to make a small color change? If you have 10 pages then you need to change the CSS code in 10 pages and if you have 100 pages then?!! So, try to link many pages to a single CSS file with the "link" tag.

4. With an external style sheet, you can change the look of an entire web site, by changing one file!

0 Comments

Leave a reply

Your email address will not be published. required fields are marked *