Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    New Coder
    Join Date
    Jun 2003
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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>

  • #3
    New Coder
    Join Date
    Jun 2003
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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

  • #4
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    Code:
    <style type="text/css">
    td{
        background-color:#e4e4e4;
    }
    </style>
    That'll give all table cells the background colour of e4e4e4

  • #5
    New Coder
    Join Date
    Jun 2003
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts
    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.

  • #6
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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

  • #7
    New Coder
    Join Date
    Jun 2003
    Posts
    29
    Thanks
    3
    Thanked 0 Times in 0 Posts

    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.

  • #8
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: background color apply to certain cells

    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

  • #9
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,266
    Thanks
    6
    Thanked 48 Times in 48 Posts
    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">

  • #10
    Senior Coder
    Join Date
    Oct 2003
    Location
    Australia
    Posts
    1,963
    Thanks
    0
    Thanked 0 Times in 0 Posts
    LOL Nightfire, beat you to it bro

    I take no responsibility for the above nonsense.


    Left Justified


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •