Are there any good reasons for using hex over deci

2019-01-08 21:12发布

rgb(255,255,255) notation has been available since CSS1. But #ffffff seems to be vastly more popular.

Obviously it's slightly more compact. I know that hex is more closely related to the underlying bytes, and understand that there would be advantages in carrying out arithmetic on those values, but this isn't something you're going to do with CSS.

Colour values tend to be originated by designers (such as myself) who would never encounter hex notation anywhere else, and are much more familiar with the decimal notation which is the main way of specifying colour in the apps they use -- in fact I have met quite a few who don't realise how a given hex value breaks down into RGB components and assumed it didn't directly relate to the colour at all, like a Pantone colour system reference (eg PMS432).

So, any reason not to use decimal?

标签: css colors hex rgb
12条回答
不美不萌又怎样
2楼-- · 2019-01-08 21:55

no valid reason, other than personal preference.

查看更多
等我变得足够好
3楼-- · 2019-01-08 22:01

Traditionally HTML has always used hex colours, so that has carried forward into CSS. Think <font color="#ffffff">

查看更多
男人必须洒脱
4楼-- · 2019-01-08 22:03

CSS was invented by software developers, not designers. Software developers live and breathe hex. From my old C64 days, I can still read most hex numbers without thinking. A9, anyone?

查看更多
做个烂人
5楼-- · 2019-01-08 22:06

Various things will accept a single hex value where they may have different ways of entering three decimal values. There's also the fact that it's always 6 characters (or 3, admittedly - plus the #) which makes it easier to scan down a list of them.

Just a couple of random thoughts to add to the mix...

查看更多
倾城 Initia
6楼-- · 2019-01-08 22:07

Hex values are easier to copy and paste from your favourite image editor.

RGB values are easier to manipulate with Javascript.

(My favourite Hex colour value is #EDEDED and a site we made for a client involved in motorsport had a background colour of #F1F1F1 :-)

Ed.

查看更多
Juvenile、少年°
7楼-- · 2019-01-08 22:07

HEX is most common due to historical reasons.

Before CSS was common in web development, colors were specified within HTML tags and the most commonly used and supported way to specify a color was to use HEX values.

查看更多
登录 后发表回答