m.edmondson
m.edmondson

Reputation: 30922

Simple question regarding CSS color code

CSS color codes are RR GG BB. So how does #26c relate to a shade of blue?

Edit:
Wow thanks for everyones help - I'll mark the answer of the one who appears to have put most effort in

Upvotes: 1

Views: 267

Answers (4)

Kyle
Kyle

Reputation: 67244

#26c is a Websafe hexadecimal colorcode. Hexadecimal colors are usually 6 characters long, for example black is #000000 and white is #ffffff. Websafe colors are only three characters long that double up, so #26c becomes #2266cc.

The reason why this relates to a shade of blue is because of the way Hexadecimal codes are calculated. 22 represents the amount of RED in the color from 1 to 255, 66 represents the amount of green in the code and CC represents the points of blue.

But how can CC represent an amount?

Well I'm glad you asked, computers like to count in amounts of EIGHT digits and so have developed a number system based on powers of 16, so you don't start over til you get to 16, but from 11 - 15 you use letters. So 10 is A, 11 is B, 12 is C, 13 is D 14 is E and 15 is F.

So when calculated using Hexadecimal, CC becomes 204 (12+12x16), meaning 204 points of blue in the color. this being the highest value, will mean the color is mostly blue :)

#000000 means 0 red, 0 green and 0 blue, that's why it is black, totally devoid of color. #ffffff means 255 red, 255 green and 255 blue, that's why it is white, all the colors added together makes white. And all the colors in between can be calculated this way :)

Hope that helps. :)

Upvotes: 5

Alan Whitelaw
Alan Whitelaw

Reputation: 16900

It's short hand, CSS doubles up each of the 3 digit codes to read #2266CC

Upvotes: 0

Yahel
Yahel

Reputation: 8540

This is the shortcut version of css, it renders as #2266CC

CC being the higher value, it should look a little blue at lease :D

Upvotes: 4

Wabbitseason
Wabbitseason

Reputation: 5691

It's a compact way of writing #2266CC

Upvotes: 2

Related Questions