CSS Color

  • What do these CSS properties do?
    • color: The CSS data type represents a color. A may also include an alpha-channel transparency value, indicating how the color should composite with its background.
    • background-color: The background-color property sets the background color of an element. The background of an element is the total size of the element, including padding and border (but not the margin).
    • border-color: The border-color property sets the color of an element’s four borders. This property can have from one to four values.
  • How does CSS accept color as a value? Provide examples of colors in these styles:
  • Named:
    • Named colors consists of standard colors, the transparent and currentcolor keywords
  • Hexadecimal
    • R or RR The red component of the color, as a case-insensitive hexadecimal number between 0 and ff (255). If there is only one number, it is duplicated: 1 means 11.
    • G or GG The green component of the color, as a case-insensitive hexadecimal number between 0 and ff (255). If there is only one number, it is duplicated: c means cc.
    • B or BB The blue component of the color, as a case-insensitive hexadecimal number between 0 and ff (255). If there is only one number, it is duplicated: 9 means 99.
    • A or AA (which is optional) The alpha component of the color, indicating its transparency, as a case-insensitive hexadecimal number between 0 and ff (255). If there is only one number, it is duplicated: e means ee. 0, or 00, represents a fully transparent color, and f, or ff, a fully opaque one.
  • RGB
    • from <color>: The keyword from is always included when defining a relative color, followed by a value representing the origin color: This is the original color that the relative color is based on. The origin color can be any valid syntax, including another relative color.
    • R, G, B: Each value can be represented as a between 0 and 255, a between 0% and 100%, or the keyword none (equivalent to 0% in this case). These values represent the red, green, and blue channel values of the output color, respectively.
    • A (which is optional): An representing the alpha channel value of the output color, where the number 0 corresponds to 0% (fully transparent) and 1 corresponds to 100% (fully opaque). Additionally, the keyword none can be used to explicitly specify no alpha channel. If the A channel value is not explicitly specified, it defaults to the alpha channel value of the origin color. If included, the value is preceded by a slash (/).

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top