Course Content
CSS Basic
0/1
CSS Selectors
0/1
CSS Comments
0/1
CSS Backgrounds
0/1
CSS Borders
0/1
CSS Outline
0/1
CSS Fonts
0/1
CSS Height and Width
0/1
CSS Margins and Paddings
0/2
CSS Icons
0/1
CSS Links
0/1
CSS Lists
0/1
CSS Tables
0/1
CSS Display Properties
0/1
CSS Max-Width Property
0/1
CSS Positioning Elements
0/1
CSS Z-Index Property
0/1
CSS Overflow
0/1
CSS Float
0/1
CSS Opacity
0/1
CSS Forms
0/1
CSS Dropdowns
0/1
CSS Buttons
0/1
CSS Media Queries
0/1
About Lesson

CSS colors allow you to specify the color of HTML elements on a webpage. Colors can be applied to various properties such as text color, background color, border color, and more. There are several ways to represent colors in CSS, including named colors, hexadecimal values, RGB values, RGBA values, HSL values, and HSLA values.

Named Colors:

Definition:

CSS provides a set of predefined color names that you can use. Some common examples include red, blue, green, yellow, etc.

Syntax:

HTML
selector {
property: namedColor;
}

Example:

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CSS Colors Example</title>
    <style>
        body {
            background-color: lightgray;
        }

        h1 {
            color: darkblue;
        }
    </style>
</head>

<body>
    <h1>Named Colors</h1>
    <p>This are Named Colors.</p>
</body>

</html>

Output: