Curriculum
Course: CSS
Login

Curriculum

CSS

CSS INTRODUCTION

0/1

CSS Selectors

0/1

CSS Comments

0/1

CSS Padding

0/1

CSS Box Model

0/1

CSS Combinators

0/1

CSS Pseudo-classes

0/1

CSS Pseudo-elements

0/1

CSS Dropdowns

0/1

CSS Image Gallery

0/1

CSS Image Sprites

0/1

CSS Counters

0/1

CSS Website Layout

0/1

CSS Specificity

0/1

CSS Math Functions

0/1
Text lesson

HEX

HEX Value

In CSS, you can define colors using hexadecimal values in the format:

#rrggbb

Where RR (red), GG (green), and BB (blue) are represented by hexadecimal values ranging from 00 to FF (equivalent to decimal 0-255).

For instance, #FF0000 corresponds to red, as red is at its maximum value (FF) while green and blue are at their minimum (00).

To represent black, all values are set to 00, like so: #000000.

Similarly, to represent white, all values are set to FF, as in: #FFFFFF.

You can experiment with different combinations of these HEX values to create various colors.

Image

Example

Image

Gray shades are frequently achieved by setting equal values for all three light sources.

Image

 

3 Digit HEX Value

Occasionally, you might encounter a 3-digit hexadecimal code in CSS files.

This abbreviated code serves as a shorthand for certain 6-digit hexadecimal codes.

The 3-digit hexadecimal code follows this structure:

#rgb

Here, R, G, and B denote the red, green, and blue components, respectively, with values ranging from 0 to F.

This shortened format is applicable only when the values for all components (RR, GG, and BB) are identical.

For example, if we have #ff00CC, it could be represented as #f0C.

Here’s an illustration for better understanding:

Example

 

body {
  background-color: #fc9; /* same as #ffcc99 */
}

h1 {
  color: #f0f; /* same as #ff00ff */
}

{
  color: #b58; /* same as #bb5588 */
}