Change Colors With An External Style Sheet

This is a quick-and-dirty tutorial which shows how to add the styles from the table coloring tutorial into an external style sheet. This is especially useful if you intend to have the same style repeated many times on more than one web page.

Step 1 - Create Blank Style Sheet

To get moving quickly, simply create a new blank document with notepad and call it mystyles.css. This document can now be used as the style sheet for your web site. If you already have an external style sheet, skip this step.

You can also download our FREE demo style sheet: demo-style-sheet.zip - 3 KB. The style sheet contains several extra styles and comes complete with a corresponding web page already linked to the style sheet so you can study how it all works.

Step 2 - Add Code To Style Sheet

Simply add the following code to mystyles.css or an existing style sheet. The demo style sheet already has this code included.

table.myclass-one {
background-color: #9932CC;
font-weight: bold;
font-size: 13px;
text-align: center;
}
td.myclass-two {
background-color: #9932CC;
color: #FFFFFF;
}
td.myclass-three {
background-color: #6B248E;
color: #EFCFFE;
}
td.myclass-four {
background-color: #EFCFFE;
color: #6B248E;
}
td.myclass-five {
background-color: #DF9FFE;
color: #6B248E;
}

Name the classes .myclass-one, .myclass-two, .myclass-three, .myclass-four, .myclass-five anything you want.

Step 3 - Add CSS Class Attributes To Table

<table class="myclass-one" width="300" height="90" cellspacing="1" cellpadding="5" border="0">
<tr>
<td class="myclass-two" colspan="3">#9932CC</td>
</tr>
<tr>
<td class="myclass-three">#6B248E</td>
<td class="myclass-four">#EFCFFE</td>
<td class="myclass-five">#DF9FFE</td>
</tr>
</table>

Step 4 - Link Document To Style Sheet

Place the following code into the head section of all the web pages which you want to reference with the style sheet.

<LINK REL="stylesheet" HREF="https://www.YourSite.com/mystyles.css" TYPE="text/css">

Obviously you should replace https://www.YourSite.com/mystyles.css with the actual URL to your style sheet.

Output

#9932CC
#6B248E #EFCFFE #DF9FFE

Using the external style sheet as outlined above will allow you to make changes on all your pages by simply editing the external style sheet (mystyles.css).