You Are Reading

ROSES ARE #FF0000, VIOLETS ARE #0000FF

Magnífica i breu explicació a Codecademy sobre els codis pels colors:

 
When you are looking at the source for pages around the Web, you may see cryptic six-digit codes in place of color names.
These are actually numbers written in base 16, or hexadecimal. Without going too far into the math, there are a few things to know:
  1. Counting in base 16 goes like this: 0123456789ABCDEF. What??
    Well, "9" means nine, "A" means ten, "B" means eleven, and so forth. So F is the highest digit you can use in hexadecimal, and it's worth fifteen.
  2. Colors represented in hexadecimal are numbers with six digits. The first two are for red, the next two are for green, the last two are for blue. Shorthand: RRGGBB.
  3. The higher the number, the brighter the pixel on the screen. So 0 is the lowest setting (black) and F is the brightest setting.
Thus, the higher the number in the "GG" position, the higher the green on your screen gets turned up. So #00FF00 means "green," since the two red digits and two blue digits are 0 but the two green digits are at their highest setting! What do you think the supplied #FF0000 means?
Note that when using hexadecimal colors, you should include a pound sign (#) before the hexadecimal number.
Make the paragraph into blue text by adjusting the hexadecimal color attribute.

Comments for this entry

Leave your comment