Always set relative to some other value ā parent
font-size is set to percentage ā it will be a percentage of the font-size of the elementās parent
width is set to percentage ā it will be a percentage of the width of parent
while many value types accept a length or a percentage, there are some that only accept length (read the docs)
Color
The standard color system available in modern computers supports 24-bit colors,
this allows displaying about 16.7 million distinct colors via a combination of different red, green, and blue channels
The calculation
Each channel (red, green, blue) has 8 bits, which can have 28=256 numbers as each bit contains 0 or 1 (hence 28)
the maximum value would be: 27+...20=255.
with 256 different values per channel, we have a total of 256 x 256 x 256 = 16,777,216 combinations
Common ways
color keywords
named colors, like greenyellow or red
hexadecimal
use 16 characters fromĀ 0-9Ā andĀ a-f, so the entire range isĀ 0123456789abcdef (16 characters/options)
Each hex color value consists of a hash/pound symbol (#) followed by six hexadecimal characters (#ffc0cb, for example)
EachĀ pairĀ of hexadecimal characters represents one of the channels of an RGB color ā red, green, and blue
Allows us to specify any of the 256 available values for each (16 x 16 = 256).
16 coz the range above
A shorthand is 3 characters, when each pairs are the same
#ff00ffā#f0f
rgb() function
takes three parameters representingĀ red,Ā green, andĀ blueĀ channel values of the colors, with an optional fourth value separated by a slash (/) representing opacity
each argument is a decimal from 0 to 255 or a percentage (but not a mixture)