Go Back   CodingForums.com > :: Client side development > HTML & CSS

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-19-2004, 07:43 PM   PM User | #1
waynefrank
New Coder

 
Join Date: Jun 2003
Posts: 29
Thanks: 3
Thanked 0 Times in 0 Posts
waynefrank is an unknown quantity at this point
Question Naming a custom color

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
waynefrank is offline   Reply With Quote
Old 02-19-2004, 07:48 PM   PM User | #2
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
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.
Code:
<style type="text/css">
.newcolour{
    color:#e4e4e4;
}
</style>
.....

<p class="newcolour">This is the new colour</p>
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 02-19-2004, 09:11 PM   PM User | #3
waynefrank
New Coder

 
Join Date: Jun 2003
Posts: 29
Thanks: 3
Thanked 0 Times in 0 Posts
waynefrank is an unknown quantity at this point
I need to define a background color

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
waynefrank is offline   Reply With Quote
Old 02-19-2004, 11:19 PM   PM User | #4
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
Code:
<style type="text/css">
td{
    background-color:#e4e4e4;
}
</style>
That'll give all table cells the background colour of e4e4e4
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 02-20-2004, 02:44 AM   PM User | #5
waynefrank
New Coder

 
Join Date: Jun 2003
Posts: 29
Thanks: 3
Thanked 0 Times in 0 Posts
waynefrank is an unknown quantity at this point
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.
waynefrank is offline   Reply With Quote
Old 02-20-2004, 02:48 AM   PM User | #6
mindlessLemming
Senior Coder

 
Join Date: Oct 2003
Location: Australia
Posts: 1,963
Thanks: 0
Thanked 0 Times in 0 Posts
mindlessLemming is an unknown quantity at this point
oh dear, what terrible overkill.
Code:
/*CSS*/ 
td {background:#ffffff}
OR
Code:
<!--HTML-->
<td style="background:#ffffff">
__________________

I take no responsibility for the above nonsense.


Left Justified
mindlessLemming is offline   Reply With Quote
Old 02-20-2004, 04:23 AM   PM User | #7
waynefrank
New Coder

 
Join Date: Jun 2003
Posts: 29
Thanks: 3
Thanked 0 Times in 0 Posts
waynefrank is an unknown quantity at this point
background color apply to certain cells

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.
waynefrank is offline   Reply With Quote
Old 02-20-2004, 04:30 AM   PM User | #8
mindlessLemming
Senior Coder

 
Join Date: Oct 2003
Location: Australia
Posts: 1,963
Thanks: 0
Thanked 0 Times in 0 Posts
mindlessLemming is an unknown quantity at this point
Re: background color apply to certain cells

Quote:
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.
Code:
.color1{background:#5e0000;}
.color2{background:#460000;}
.color3{background:#ffffcc;}
___________________________________

<td class="color1">...........
<td class="color2">...........
You get the picture.

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.
__________________

I take no responsibility for the above nonsense.


Left Justified
mindlessLemming is offline   Reply With Quote
Old 02-20-2004, 04:30 AM   PM User | #9
Nightfire
Senior Coder

 
Nightfire's Avatar
 
Join Date: Jun 2002
Posts: 4,266
Thanks: 6
Thanked 48 Times in 48 Posts
Nightfire is on a distinguished road
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.

Code:
<style type="text/css">
.waynescolor{
    background-color:#ff0000;
}
</style>
Then for the cells you want colouring in,

<td class="waynescolor">
__________________
Blue Panda
Website Design | 1 Pound Ads | 'ow much? | Coding Geeks
Nightfire is offline   Reply With Quote
Old 02-20-2004, 05:02 AM   PM User | #10
mindlessLemming
Senior Coder

 
Join Date: Oct 2003
Location: Australia
Posts: 1,963
Thanks: 0
Thanked 0 Times in 0 Posts
mindlessLemming is an unknown quantity at this point
LOL Nightfire, beat you to it bro
__________________

I take no responsibility for the above nonsense.


Left Justified
mindlessLemming is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:18 PM.


Advertisement
Log in to turn off these ads.