Tuesday 7, February 2012
Welcome Guest, Register | Login  
      Home    |    Tutorials    |    Free Ebooks    |    Free Scripts    |    Articles    |    Blog     |    Forum    |    About Us    |    Contact Us

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 a ".css" file extension. This CSS file is then referenced in your HTML using the instead of . If you're confused, don't worry. We are going to walk you through the whole process.

File Creation
Let us get started by making that external CSS file. Open up notepad.exe, or any other plain text editor and type the following CSS code.

CSS Code:
body{ background-color: gray;}
p { color: blue; }
h3{ color: white; }
Now save the file as a CSS (.css) file. Make sure that you are not saving it as a text (.txt) file, as notepad likes to do by default. Name the file "test.css" (without the quotes). Now create a new HTML file and fill it with the following code.

HTML Code:
<html>
<head>
<link href="/style.css" rel="stylesheet" type="text/css" />
</head>
<body>

<h3> A White Heading </h3>
<br />
<p> This paragraph will have a blue font. <br />
The background color of this page will be gray because<br />
we changed it with CSS! </p>

</body>
</html>

Then save this file as "index.html" (without the quotes) in the same directory as your CSS file. Now open your HTML file in your web browser and it should look something like this.
This paragraph has a blue font. The background color of this page is gray because we changed it with CSS!
Why Use External CSS?
• 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 many 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.

 

 
     
   
CSS Tutorial
 
  Introduction
Introduction
  Syntax
Syntax
  Internal CSS
Internal CSS
  External CSS
External CSS
  Inline CSS
Inline CSS
  CSS Classes
CSS Classes
  CSS Background
CSS Background
  CSS Text
CSS Text
  CSS Font
CSS Font
  CSS Border
CSS Border
  CSS Outline
CSS Outline
  CSS Padding
CSS Padding
  CSS Margin
CSS Margin
  CSS Lists
CSS Lists
  CSS Tables
CSS Tables
 
 
 
Web Designing Tutorials
  HTML Tutorial
HTML Tutorial
  DHTML Tutorial
DHTML  Tutorial
  CSS Tutorial
CSS Tutorial
  XHTML Tutorial
XHTML Tutorial
 
Programming Languages Tutorials
  C Language Tutorial
C Language Tutorial
  C++ Tutorial
C++ Tutorial
  Java Language Tutorial
Java Language Tutorial
  Data Structure Theory Tutorial
Data Structure Theory Tutorial
 
Server Side Scripting Tutorials
  PHP Tutorial
PHP Tutorial
  SQL Tutorial
SQL Tutorial
  ASP Tutorial
ASP Tutorial
 
Client Side Scripting Tutorials
  JavaScript Tutorial
JavaScript Tutorial
  VBScript Tutorial
VBScript Tutorial
 
 
 
POPULAR E-BOOKS
 
Download 	JavaScript Essentials Ebook JavaScript Essentials
   
Download Creating XPCOM Components  Ebook Creating XPCOM Components
   
Download Blueprints for a successful presentation  Ebook Blueprints for a successful presentation
   
Download The Definitive Guide to symfony  Ebook The Definitive Guide to symfony
   
Download Sonic Forex Trading System  Ebook Sonic Forex Trading System
   
 
Studiesinn.com © 2012 All Rights Reserved.
Website Designed & Developed by TechXprtz