SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    matching color name to color code

    some color names are not matched to color codes by one to one.

    The color name "violet" as an example,
    some say the code of it "#8F00FF".
    some say the code of it "#7F00FF".
    some say the code of it "#8601AF".
    some say the code of it "#EE82EE".

    What is the correct code of the color name "violet"?

    The color code of RGG seems to be defferent from the HTML color code.
    The color code of color wheel seems to be defferent from the RBG color code.


    For web publishing what color code should I always use?

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Probably a better approach is just pick a color you like in Photoshop and not worry about it. For me, Photoshop says that violet is

    #ee82ee

    rgb(238, 130, 238)

  3. #3
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    I have some color classes in my css file for using them in my webpage.
    Code:
    .red {color:#ff0000}
    .blue {color:#0000ff}
    .black {color:#000000}
    :      :
    In this case I have to get the correct color code which matches to the color name.

  4. #4
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    It's not a good idea to use classes with names like that. If you have elements all over the place with class="red" and you decide to color them blue, that will look rather silly.

    The color codes you listed there are the correct codes for those colors.

  5. #5
    Get my greedy down dotJoon's Avatar
    Join Date
    Apr 2003
    Location
    daejeon, South Korea
    Posts
    2,223
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ralph.m View Post
    If you have elements all over the place with class="red" and you decide to color them blue, that will look rather silly.
    I won't decide to color them blue.
    I like to make users to use it when they are posting
    I guess "<span class="red">red text</span>" is much better than"<span style="color:#ff0000">red text</span>" to users.

  6. #6
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    24,173
    Mentioned
    454 Post(s)
    Tagged
    8 Thread(s)
    Quote Originally Posted by dotJoon View Post
    I guess "<span class="red">red text</span>" is much better than"<span style="color:#ff0000">red text</span>" to users.
    Yeah, but I didn't say to do that. What if you decide later that red is not a good color for users who are posting? So a better thing to do is use something like this:

    Code:
    <span class="post">post text</span>
    
    .post {color: red;}
    That way, you can style posts (inside the .post span) any way you like, without your code looking odd if you have "red" classes styled with a different color.

    It's just a bad idea in general to name classes after an appearance of any kind. Make the class names rather focus on the role of the element.

  7. #7
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    The 'color keywords' are limited though and not consistent amongst browsers even the WCAG suggested against using them, i.e. use numbers, not names, for colours. If you want a rough guide though what numbers "violet" may loosely equate to: http://www.w3.org/TR/css3-color/#svg-color
    Last edited by Dark Tranquility; Sep 23, 2012 at 04:57.

  8. #8
    Mouse catcher silver trophy Stevie D's Avatar
    Join Date
    Mar 2006
    Location
    Yorkshire, UK
    Posts
    5,888
    Mentioned
    122 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by xhtmlcoder View Post
    The 'color keywords' are limited though and not consistent amongst browsers even the WCAG suggested against using them, i.e. use numbers, not names, for colours. If you want a rough guide though what numbers "violet" may loosely equate to: http://www.w3.org/TR/css3-color/#svg-color
    And remember that that is a new feature in CSS3, which is a long way from being ready for deployment. In CSS1 and CSS2, the only legal colour names are the the basic 16 colours (white, black, gray, silver, blue, navy, lime, green, red, maroon, fuscia, purple, aqua, teal, yellow, olive), and that for any other colours you must use #hex or (r,g,b) codes. Most browsers will play ball with named colours, because they try to do what they think authors want, but it isn't guaranteed.

    (HTML 4, on the other hand, does allow you to use all named colours, except that you wouldn't stoop so low as to declare a colour in HTML now, would you!)

  9. #9
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Obviously that is why I said numbers not names as that (see link) basically was based on X11, I think Fred5 will be intending on using those CSS matches. CSS 2.1 has 17: aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, [orange], purple, red, silver, teal, white, and yellow. Though of course really you should avoid using those 'keywords' also.

    The use of HTML elements and attributes for specifying colour is deprecated anyway so that usage should have stopped well over 10-years ago since the only places you could use the 'color' attribute was BASEFONT and FONT. LOL. The only other places you could apply colour values (keywords) being obviously: bgcolor, text, link, alink and vlink - again all deprecated for good reason. In otherwords use numbers not names.


Bookmarks

Posting Permissions

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