CSS: Colors & Units

Learn how to use colors and measurement units in CSS to style your web pages.

CSS Colors

CSS allows you to define colors using various formats:

/* Example */
body {
    background-color: #f0f0f0;
    color: rgb(0, 0, 0);
}
        

CSS Units

CSS uses various units to define sizes, spacing, and more:

/* Example */
h1 {
    font-size: 2em; /* Relative to parent element */
    margin: 10px;  /* Absolute unit */
}
        

Practice

Try experimenting with different color formats and units:

Continue Learning

Quick Check

Which color function includes an alpha (transparency) channel?