00 Votes

CSS: What's the meaning of short color specifications like #FFF instead of #FFFFF?

Question by Guest | 2014-02-03 at 10:02

Some years ago in school, I have learned that hexadecimal RGB color specifications always have six digits. So, for example 6-digit values like #FFFFF, #00000 or #CA03EE.

However, when browsing the source code of several website, quite often, I can see 3-digit specifications such as #FFF or #000.

So, what's it all about? Is that even allowed? And how can you convert the information from one system into the other?

ReplyPositiveNegative
0Best Answer0 Votes

#FFF is just a short form of #FFFFFF. These short values are easier to write and they need less space and memory.

Whenever a hexadecimal color specification consists of equal pairs, you can use such an abbreviation. For example, the color #AA00FF can be shortened to #A0F, but it is not possible to abbreviate the color #A00AFF because this color consists of the RGB parts  A0 0A and FF which are not only pairs.

I do not know any browser not understanding this values, so it is your turn whether you would like to use this shorter values or not. There will be no difference in the appearance of a website depending on which of the values you are using.
2014-02-03 at 17:59

ReplyPositive Negative
Reply

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.