开发者

background-color: white - ok or should hexidecimal be used? [duplicate]

This question already has answers here: 开发者_Python百科 Closed 11 years ago.

Possible Duplicate:

Are there any cons to using color names in place of color codes in CSS?

When specifying colors and background colors in CSS, is it ok to use words like 'white' rather than the hexidecimal value? It seems to work fine for me but are they any issues with other devices or older browseres?

Thanks


Color shoud be used with HEX value not by name, coz that has been deprecated; see the latest document:

http://www.w3.org/TR/WCAG10-CSS-TECHS/#style-color-contrast


This is taken from the W3C specification. And it clearly tells that names are depreciated. Its only kept for legacy reasons.

Techniques:

Use numbers, not names, for colors.
Example.

Use numbers, not names, for colors:

   H1 {color: #808000}
   H1 {color: rgb(50%,50%,0%)}
Deprecated example.

 H1 {color: red}
Use these CSS properties to specify colors:

'color', for foreground text color.
'background-color', for background colors.
'border-color', 'outline-color' for border colors.
For link colors, refer to the :link, :visited, and :active pseudo-classes.


There are a number of colors that are defined within the CSS specification so any CSS compliant browser will display your color correctly.


Personally I like using the color name when possible. Even though the hexidecimal value is pretty obvious that its white/black, I do find it much easier to pick out the color when its white. That being said, I don't think there are names for all of the colors, so sometimes hexidecimals are necessary.

But in the end, both are acceptable.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜