Web Design Stuff
HTML Tutorials    CSS Tutorials    Web Hosting   Resources
Create a Web Page 101
Making Web Pages Intro What is a Web Page? Why Make a Web Page? The History of HTML Learn HTML or XHTML?
Basic HTML
Basic HTML Tutorials Basic HTML Necessities How to Make a Web Page How to Edit a Web Page The Basics of HTML Tags Basic HTML Page Structure HTML Attributes
HTML Font Codes
HTML Font Codes Intro HTML Font Color Codes HTML Font Size Codes HTML Font Style Codes HTML Bold/Italic Codes Combining Font Codes
Formatting Text
Formatting Text Intro Making Paragraphs Miscellaneous Formatting Headings & Subheadings Creating Hyperlinks
Using Graphics
Using Graphics on the Web Add Graphics to Your Pages Graphics and Accessibility How to Align Graphics Page Color & Background Graphics as Hyperlinks Horizontal Rules
Creating Tables
HTML Tables Tutorials HTML Table Fundamentals Background & Border Color Table Frames & Rules Table Width and Alignment Cells 1 -Space & Alignment Cells 2 -Row Column Span Cells 3 -Width & Height
Making Lists
HTML Lists Tutorials Bulleted Lists Numbered Lists Definition Lists
HTML Frames
HTML Frames Tutorials Using Frames for Layout Advanced Frame Layouts Putting Hyperlinks in Frames Frame Border Width Color, Margin and Control Problems with Frames SmartFrames: A Solution SSI: An Alternative to Frames
Web Page Forms
Making Feedback Forms A Simple Feedback Form Installing NMS FormMail Debugging Your Setup My Web Host is Out to Lunch User Input Components Text Fields Checkboxes & Radio Buttons Dropdown Menus Push Buttons Layout and Presentation
Basic CSS
Basic CSS Tutorials What is CSS? Why You Should Use CSS How to Use CSS Inline Styles Embedded Style Sheets External Style Sheets Class Selectors ID Selectors Combining Selectors
CSS Properties
CSS Properties Intro Font Styles Width, Height & Spacing Borders Backgrounds Position Float & Alignment Hyperlinks
All About Web Hosting
Hosting Your Own Website What is a Web Host? Your Website's Home Page Building a Website Offline About Free Web Hosting Best Free Web Hosting Commercial Web Hosting How to Get a Domain Name Ecommerce Web Hosting Web Hosting Terminology
Free Web Design Tools
Best Free Website Tools Best Free Text Editors Best Free Graphics Editors Free Website Analysis Tools
Setting Up HTML Kit
HTML Kit Introduction How to install HTML Kit Screenshot Breakdown Basic Configuration Overall Appearance Shortcuts and Startup Editing Window Customizing Toolbars Using the Favorites Tab Making a New Actions Bar Odds and Ends
Free Templates
Free Website Templates Two Column Fixed Width Three Column Liquid Layout Miscellaneous Templates Dynamic Menu Effects Two Column Experimental Terms of Use About These Templates
Website Templates Help
Getting Started Template Zip File Download How to Edit Your Template What to Edit in the HTML How to Add Your Logo Making a Website
Web Design Tips
Web Design Basics Tables vs. Tableless Using Tables for Layout Example Table Layouts World's Crappiest Web Page
Twitter Backgrounds
Twitter Backgrounds Intro Cool Twitter Backgrounds Cool Twitter Backgrounds 2 Plain Twitter Backgrounds Dark Twitter Backgrounds Best Twitter Backgrounds Cute Twitter Backgrounds Music Twitter Backgrounds Music Twitter Backgrounds 2 Twitter Backgrounds 101 TERMS OF USE
All About Web Browsers
What is a Web Browser? Mozilla Firefox Internet Explorer Opera How to Set Up Firefox Top 5 Firefox Extensions
 
Contact
Post Some Feedback Send Me An Email Iron Spider Blog About Iron Spider... Site Conventions
 
 
 

 

External Style Sheets

 
Using external style sheets is the ultimate webmaster's tool in that it allows you to apply formatting to many different web pages at once with a single .css file. In fact, once you become adept at using style sheets, this will be —and should be— your go-to method of applying CSS.

How to Create an External Style Sheet


An external style sheet is simply a text file containing a list of CSS rules sets. The file is saved with a .css extension and saved to any directory that can be accessed by the web pages using it. Unlike embedded style sheets, the CSS rules sets do not have to be wrapped in the <style>...</style> tags.

Here's an example using the same rule sets as those on the previous page in this tutorial:

Example 1 - CSS RULE SETS IN AN EXTERNAL STYLE SHEET

H1 {
   font-family: 'Times New Roman';
   font-size: 36px;
   background: #ffffff;
   color: maroon;
}

H2 {
   font-family: arial,verdana,sans-serif;
   font-size: 20px;
   background: #ffffff;
   color: black;
}

P {
   font-family: arial,verdana,sans-serif;
   font-size: 16px;
   background: #ffffff;
   color: navy;
}



Now all we have to do is save the above rule sets to a file called, say, main.css and presto, you've got an external style sheet.

So how do you get your web pages to use this style sheet? Well this is accomplished using...


The link Element


The link element can be used, among other things, to specify that a web page should use an external style sheet. The link element only requires a start tag <link> and is inserted in between the <head>...</head> tags of your web page (a.k.a., document head). It can be used as many times as you like.

The link element employs three important attributes: rel, type and href. For CSS, the value of the rel attribute is always stylesheet and the value of the type attribute is always text/css. The only part of the code you really have to concerned with is the value of the href attribute which will change according to which .css file you're referring to. This value can be any relative or absolute path.

Here's an example of the link element inserted in the document head of a web page:

Example 1 - THE link ELEMENT DISPLAYED IN THE DOCUMENT HEAD

<html>

<head>
<title></title>

<link rel="stylesheet" type="text/css" href="main.css">

</head>

<body>
...web page content...
</body>

</html>



In the above, the link element specifies that the web page should use an external style sheet called main.css.

Now... here's the magic of it:

Since you can have as many web pages as you like using the link element to refer to the same external style sheet, i.e., main.css, then what you have essentially done is created a kind of central hub to apply formatting to many different web pages at once.

Click here to view an example of a web page using an external style sheet...

Click here to view another web page using the same external style sheet...


Heh heh! Now we're cooking with gas, right?


*   *   *


Right. So now you're thinking that you would like to make some paragraphs with green text and other paragraphs with blue text (*chuckle*... or something like that) and can this be done using CSS?

Well most certainly!

Let's move on to learn how to create class selectors which will help you target specific web page components...


SEE ALSO:
  • What is CSS?
  • How to use CSS - An Overview
  • Inline styles
  • Embedded Style Sheets
  • CSS Properties




Best Free Stuff
for webmasters

Free Text Editors
Free Graphics Editors
Website Analysis Tools
Free Website Templates

See also:

Best Free Web Hosting
How to Make a Web Page

 

If you need a .COM web address, you can get one quick and easy at...

www.GoDaddy.com
<~ BACK TOP NEXT ~>
 
HTML Tutorials |  CSS Tutorials |  Web Hosting |  Domain Names |  Web Design Resources
Iron Spider © Copyright 2004-2011 Robert Darrell