External Stylesheets

External StylesheetsAs you can probably tell from the name this means having an external file and then linking to it from your page so you don't have all that code in your head tags in every single page. This is a lot easier than it may seem, first of all open notepad and copy the following code:

body {
 background-color: #000000;
 color: #FFFFFF;
 text-decoration: underline;
 font-family: Courier New", Courier, monospace;
}

When you have copied this into notepad, save the file as mystyle.css. (You may need to write "mystyle.css" for this to work). The *.css is important because you are saving this file as a cascading stylesheet and this is the file extension for these. Now you have this saved make sure it is in the same folder as your HTML page.

In your HTML page, inside the head tag, where we would normally put the <style type="text/css"> part of the code, instead of using this we will link to our already made external stylesheet. The code for linking to an external stylesheet is:

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

The only part of this code you will ever need to change is the href="mystyle.css" part (Location of the stylesheet). You will need to change the filename to whatever you have decided to call the external stylesheet, in this case its called 'mystyle.css' but sometimes the directory of the file may change, depending on where you put the file. This is the full example of what your HTML page will look like.

<html>
<head>
<title>External Stylesheet</title>

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

<body>
</body>
</html>

If you have done everything correctly then you will have linked to your external stylesheet which will have loaded the attributes:

body {
 background-color: #000000;
 color: #FFFFFF;
 text-decoration: underline;
 font-family: Courier New", Courier, monospace;
}

In every page you have linked to this stylesheet the background colour will be black, the font colour will be white, ECT. This is much easier than writing all the CSS in the head of each page.


Close    To Top
  • Prev Article-Web Design:
  • Next Article-Web Design:
  • Now: Tutorial for Web and Software Design > Web Design > HTMLCSS > Web Design Content
    Photoshop Tutorial
     

    Special Effect

      3D Effect
      Photoshop Articles
    Programming Tutorial
     

    C/C++ Tutorial

      Visual Basic
      C# Tutorial
    Database Tutorial
     

    MySQL Tutorial

      MS SQL Tutorial
      Oracle Tutorial
    Geek Tutorial
     

    Blogging Tutorial

      RSS Tutorial
      Podcasting Tutorial
    Graphic Design Tutorial
      Coreldraw Tutorial
      Illustrator Tutorial
      3D Tutorials
    Webmaster Articles
     

    Domain Service

      Web Hosting
      Site Promotion
    Java Tutorial/ Articles
     

    Java Servlets

      JavaEE Tutorial
     

    JavaBeans Tutorial

    XML Tutorial/ Articles
     

    XML Style

      AJAX Tutorial
      XML Mobile
    Flash Tutorial/ Articles
     

    Flash Video

      Action Script
      Flash Articles
    OS Tutorial/ Articles
      Linux Tutorial
      Symbian Tutorial
      MacOS Tutorial
    Personal Tech
      Hardware Tutorial
      Software Tutorial
      Online Auction