Document directory
- What's external CSS
- Example
- Why use external CSS file?
Quoted from http://www.tizag.com/cssT/external.php
What's external CSS
When using CSS it is preferable to keep the CSS separate from your HTML. placing CSS in a separate file allows the web designer to completely differentiate between content (HTML) and design (CSS ). external CSS is a file that contains only CSS Code and is saved with ". CSS "file extension. this CSS file is then referenced in your HTML using the <link>InsteadOf <style>. If you're confused, don't worry. We are going to walk you through the whole process.
Example
This is a HTML file named index.html: 1 <HTML>
2
3 <LINK rel = "stylesheet" type = "text/CSS" href = "test.css"/>
4
5 <body>
6 7 <p> This paragraph has a blue font.
8 The background color of this page is gray because
9 we changed it with CSS! </P>
10 </body>
11
Make sure save this file as "index.html" (without the quotes) in the same directory as your CSS file.
Why use external CSS file?
- It keeps your website design and content separate.
- It's much easier to reuse your CSS code if you have it in a separate file. instead of typing the same CSS code on every web page you have, simply have pages refer to a single CSS file with the "Link" tag.
- You can make drastic changes to your web pages with just a few changes in a single CSS file.