...

View Full Version : Naming a custom color



waynefrank
02-19-2004, 07:43 PM
How can I give a custom color a name? I want to define a custom color in a stylesheet and then refer to it by name in the HTML. Then if I want to change the color, I can just change the stylesheet, rather than change each reference on each page.

Thanks,

Wayne McKinstry

Nightfire
02-19-2004, 07:48 PM
I think you got the idea of css wrong. You don't need to name a colour in html to get a colour in css to work.


<style type="text/css">
.newcolour{
color:#e4e4e4;
}
</style>
.....

<p class="newcolour">This is the new colour</p>

waynefrank
02-19-2004, 09:11 PM
I should have been more specific. What I want is to define a color for table cell backgrounds. How can I do this, so that they can all be changed from the spreadsheet??

Thanks

Nightfire
02-19-2004, 11:19 PM
<style type="text/css">
td{
background-color:#e4e4e4;
}
</style>

That'll give all table cells the background colour of e4e4e4

waynefrank
02-20-2004, 02:44 AM
I realized what I can do

<td background="leftstripcolor.jpg"

for the cells I want to have the background color. I make the jpg the color I want. :D

mindlessLemming
02-20-2004, 02:48 AM
oh dear, what terrible overkill.


/*CSS*/
td {background:#ffffff}

OR

<!--HTML-->
<td style="background:#ffffff">

waynefrank
02-20-2004, 04:23 AM
I want to make this background color apply to certain cells, and not others. And I wanted to be able to change that color without going thru and changing each page.

What I originally wanted was to be able to define "waynescolor" and then set backgrounds to that. This method with the jpg is the next best thing.

mindlessLemming
02-20-2004, 04:30 AM
Originally posted by waynefrank

What I originally wanted was to be able to define "waynescolor" and then set backgrounds to that. This method with the jpg is the next best thing.

No, its not.
The next best thing is this.

.color1{background:#5e0000;}
.color2{background:#460000;}
.color3{background:#ffffcc;}
___________________________________

<td class="color1">...........
<td class="color2">...........

You get the picture. :D

P.S, If you really were going to use an image (which you will NEVER need to for a solid colour) you would use .gif, not .jpg.

Nightfire
02-20-2004, 04:30 AM
The method with the jpg is the worst thing. You're just adding extra load on your pages for absolutely no reason at all. Now if you said you didn't want it on all cells to start off with, I would've saved you and me the bother of giving you css which is no use to you.



<style type="text/css">
.waynescolor{
background-color:#ff0000;
}
</style>

Then for the cells you want colouring in,

<td class="waynescolor">

mindlessLemming
02-20-2004, 05:02 AM
LOL Nightfire, beat you to it bro ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum