• Home

Logo

Navigation
  • Home
  • Articles
    • Content Writing
    • Design
    • General
    • Internet Marketing
    • Social Media
    • Tools and Tips
    • Usability
    • Web Hosting Articles
  • Tutorials
    • AJAX Tutorials
    • ASP Tutorials
    • C# Tutorials
    • CGI and Perl Tutorials
    • CSS Tutorials
    • Flash Tutorials
    • HTML Tutorials
    • Illustrator Tutorials
    • Java Tutorials
    • JavaScript Tutorials
    • Linux Tutorials
    • Miscellaneous Tutorials
    • MySQL Tutorials
    • Photoshop Tutorials
    • PHP Tutorials
    • Python Tutorials
    • Wireless Tutorials
    • WordPress Tutorials
    • XML Tutorials
  • Scripts
    • AJAX Scripts
    • ASP Scripts
    • ASP.NET Scripts
    • CGI & Perl Scripts
    • Flash Scripts
    • Java Scripts
    • JavaScript Scripts
    • PHP Scripts
    • Python Scripts
    • Remotely Hosted
    • Tools and Utilities
    • XML Scripts
  • Answers
  • Online Services
  • Tools

Creating and Linking External CSS files

By Ades Tynyshev | on May 31, 2005 | 0 Comment
CSS Tutorials
  • Tweet
  • Share
  • Tweet
  • Share

Creating and Linking External CSS files

It is particularly useful to keep one css file for the entire website rather than having individual CSS styles in every page, advantage of having a separate CSS file is, it is easy to update and maintain the look and feel of the entire website from a single file. That is why it is better to create an external CSS file if you have not done so. This tutorial will show you how to convert your internal CSS styles to an external file and how to attach them to a page.

This is how we normally define an internal CSS style:

<style type="text/css">

<!–
.allContent {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
}

–> 

</style>

To convert this style to an external file is very easy, just copy the code (only the ones in red) into Notepad and save it as style.css

Note: If you are creating a totally new CSS file then you have to follow this structure:

.StyleName { properties }

Properties here should be defined as shown above in the notepad, property-name: value;

Now open an existing html page (or create a new html page, and save it as myStyle.html in the same folder as your style.css file). In the source code of the page between the <head></head> tags add the following line:

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

This will attach your style.css file to the page.

We have created external CSS file then we have linked it to the page and now let’s apply this CSS style to the content of the page. Applying CSS style inside the page can be achieved in few ways, here we are going to use only <span> tags. Span tags are used this way:

<span style="allContent">Content Comes Here</span>

All the content between these <span> tags will be having your allContent style properties, that is font size will be 10 pixel and all the font face will be Arial, Helvetica.

So the source code of your page basically should look like this:

<head>
<title>My Page</title>

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

</head>
<body>

<span class="allContent">Content Comes Here</span>

</body>
</html>

Share this story:
  • tweet

Author Description

No Responses to “Creating and Linking External CSS files”

You must be logged in to post a comment.

Connect With Us

RSSSubscribe 0Followers 494Likes
  • Popular
  • Recent
  • Comments
  • Creating Energy Spheres in Photoshop

    Apr 15, 2008 - 96 Comments
  • Easy Screen Scraping in PHP with the Simple HTML DOM Library

    Aug 6, 2008 - 20 Comments
  • Calculating date difference more precisely in PHP

    Mar 7, 2008 - 13 Comments
  • When Does Hosting Your Website in the Cloud Make Sense?

    Oct 8, 2010 - 2 Comments
  • Fun with the Microsoft Managed Extensibility Framework Part 2

    Oct 6, 2010 - 0 Comment
  • Fun with the Microsoft Managed Extensibility Framework Part 1

    Sep 22, 2010 - 0 Comment
  • Website Management on the go with the iPad

    I appreciated your post, but I was looking for something I didn't...
    November 24, 2012 - drmoderator
  • Creating Energy Spheres in Photoshop

    I'm a little stuck down here especially at the step of creating the...
    November 23, 2012 - sarah
  • Running background processes in PHP

    Can you give an example? As see it, you can use this only when you...
    November 16, 2012 - Shaked Klein Orbach
Developer Resources
  • Tutorial Directory
  • Learn HTML
  • Learn PHP
  • Learn CSS
  • Learn AJAX
  • Learn JavaScript
  • Learn Pear
  • White Papers
  • Resources
    • NetVisits Web Directory
    • Realtor Pixels
    • Answers On The Run
    • Ask A Geek
  • Recent Posts

    • When Does Hosting Your Website in the Cloud Make Sense?
    • Fun with the Microsoft Managed Extensibility Framework Part 2
    • Fun with the Microsoft Managed Extensibility Framework Part 1
    • Website Management on the go with the iPad
    • Code Contracts in C# 4.0 – Part 1

    Calendar

    May 2013
    M T W T F S S
    « Oct    
     12345
    6789101112
    13141516171819
    20212223242526
    2728293031  

    Recent Comments

    • drmoderator on Website Management on the go with the iPad
    • sarah on Creating Energy Spheres in Photoshop
    • Shaked Klein Orbach on Running background processes in PHP
    • Thomas Cuvillier on How To Upload Files Using PHP
    • rizal aditya on Extracting text from Word Documents via PHP and COM
    • Home
    © 2003 - 2013 DeveloperTutorials.com. All Rights Reserved. Privacy Policy.