Web Analytics Made Easy -
StatCounter Naming a custom color - CodingForum

Announcement

Collapse
No announcement yet.

Naming a custom color

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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>

    Comment


    • #3
      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

      Comment


      • #4
        Code:
        <style type="text/css">
        td{
            background-color:#e4e4e4;
        }
        </style>
        That'll give all table cells the background colour of e4e4e4

        Comment


        • #5
          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.

          Comment


          • #6
            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

            Comment


            • #7
              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.

              Comment


              • #8
                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

                Comment


                • #9
                  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">

                  Comment


                  • #10
                    LOL Nightfire, beat you to it bro

                    I take no responsibility for the above nonsense.


                    Left Justified

                    Comment

                    Working...
                    X