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>