YogeshChauhan.com
How to link/add CSS file to HTML Document?
March 31, 2020

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!

dreamhost

Leave a Reply

Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 How to set opacity or transparency using CSS? #3 Pagination in CSS with multiple examples #4 How to make HTML form interactive and using CSS? #5 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

Mar 3 How to embed YouTube or other video links in WordPress? Mar 3 How to change the Login Logo in WordPress? Mar 3 substring() Method in JavaScript Mar 3 Window setInterval() Method in JavaScript Mar 2 How to zoom an element on hover using CSS? Mar 2 the box-sizing property in CSS

You might also like these

List of all Pseudo Elements in CSSCSSWhere is the PHP log file located on Mac OS?PHPMicroservices vs Monolithic ArchitectureMiscWhat are Web services?MiscHow to add a ribbon inside a container using CSS?CSSHow to get recent posts in WordPress?WordPress