I know this sounds a bit absurd, but I'd be really interested if there was a real answer. In CSS color attributes like color: or background-color:, is it preferable to use a hexadecimal value (#000) or a keyword (black)?
On one hand, one is more readable. On the other hand, the other is far more specific, won't do anything weird, and, most of the time, takes up less bytes.
Or is this whole question irrelevant?
Should one use "black" or "#000"?
Moderator: General Moderators
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US
-
method_man
- Forum Contributor
- Posts: 257
- Joined: Sat Mar 19, 2005 1:38 am
Re: Should one use "black" or "#000"?
Of course there is an answer. These are the type of people that write standards that include how many PIXELS specific FONTS should shift when tables meet layers meeting div's.. you get the idea. They dictate everything under the sun.Ambush Commander wrote:I know this sounds a bit absurd, but I'd be really interested if there was a real answer. In CSS color attributes like color: or background-color:, is it preferable to use a hexadecimal value (#000) or a keyword (black)?
Now, with that out of the way, yes, short hex code colors are also shorter (less bandwidth), better supported (all the way back to NS4), AND make it easier to avoid using non-websafe colors (most of the 3-digit codes are websafe).WebStandard wrote: There are sixteen (16) legal color names for use in HTML 4.x and XHTML. Any other color name is a browser-specific name and cannot be used in conforming HTML 4.x and XHTML documents.
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
- Ambush Commander
- DevNet Master
- Posts: 3698
- Joined: Mon Oct 25, 2004 9:29 pm
- Location: New Jersey, US