背景颜色:白色 - 好的还是应该使用十六进制?
在 CSS 中指定颜色和背景颜色时,可以使用“白色”等单词而不是十六进制值吗?它似乎对我来说工作得很好,但是其他设备或旧浏览器有什么问题吗?
谢谢
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
颜色应与十六进制值一起使用,而不是按名称使用,因为它已被弃用;请参阅最新文档:
http://www.w3。 org/TR/WCAG10-CSS-TECHS/#style-color-contrast
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
这取自 W3C 规范。它清楚地表明名称已贬值。它只是出于遗留原因而保留。
This is taken from the W3C specification. And it clearly tells that names are depreciated. Its only kept for legacy reasons.
CSS 规范 中定义了多种颜色因此任何兼容 CSS 的浏览器都会正确显示您的颜色。
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.