CSS
CSS Colors - Valid Color text,Keyword Colors, Hexadecimal, RGB, HSL,HSLA Colors
CSS (Cascading Style Sheets) allows you to define colors using a variety of methods. Here are some common ways to specify colors in CSS along with examples:
¶Keyword Colors:
CSS provides a set of named color keywords that you can use. Here are a few examples:
color: red;
background-color: blue;
¶Hexadecimal Colors:
You can specify colors using hexadecimal values, which represent the red, green, and blue (RGB) components. Hexadecimal colors are prefixed with a #
. For example:
color: #FF0000; /* Red */
background-color: #00FF00; /* Green */
¶RGB Colors:
You can specify colors using the RGB function, which allows you to specify the red, green, and blue values. Here’s an example:
color: rgb(255, 0, 0); /* Red */ RGBA Colors: RGBA is similar to RGB but includes an alpha channel for transparency. You can specify the opacity as a value between 0 and 1. For example:
background-color: rgba(0, 0, 255, 0.5); /* Semi-transparent blue */
¶HSL Colors:
HSL stands for Hue, Saturation, and Lightness. It’s another way to specify colors. Here’s an example:
color: hsl(120, 100%, 50%); /* Green */
¶HSLA Colors:
HSLA is similar to HSL but includes an alpha channel for transparency. For example:
background-color: hsla(0, 100%, 50%, 0.5); /* Semi-transparent red */
¶Named Colors:
CSS also includes a list of named colors that you can use. Some common named colors include “red,” “green,” “blue,” “yellow,” and more.
Here’s a simple HTML and CSS example that demonstrates the use of some of these color methods:
<!DOCTYPE html>
<html>
<head>
<style>
.red-text {
color: red;
}
.hex-text {
color: #00FF00;
}
.rgb-text {
color: rgb(0, 0, 255);
}
.hsl-text {
color: hsl(120, 100%, 50%);
}
.named-text {
color: blue;
}
</style>
</head>
<body>
<p class="red-text">This is red text.</p>
<p class="hex-text">This is green text using hexadecimal color.</p>
<p class="rgb-text">This is blue text using RGB color.</p>
<p class="hsl-text">This is green text using HSL color.</p>
<p class="named-text">This is blue text using a named color.</p>
</body>
</html>
In this example, each paragraph uses a different method to set the text color. You can create similar styles for background colors and experiment with different color values to achieve your desired look.
The Fundamental Concept in Web design and Layout of CSS Box Model.
CSS Texts - Color, Alignment, Decoration, transformation, Spacing - letter-spacing, text-indent, line-height
All Tutorials in this playlist
Popular Tutorials
Categories
-
Artificial Intelligence (AI)
11
-
Bash Scripting
1
-
Bootstrap CSS
0
-
C Programming
14
-
C#
0
-
ChatGPT
1
-
Code Editor
2
-
Computer Engineering
3
-
CSS
28
-
Data Structure and Algorithm
18
-
Design Pattern in PHP
2
-
Design Patterns - Clean Code
1
-
E-Book
1
-
Git Commands
1
-
HTML
19
-
Interview Prepration
2
-
Java Programming
0
-
JavaScript
12
-
Laravel PHP Framework
37
-
Mysql
1
-
Node JS
1
-
Online Business
0
-
PHP
28
-
Programming
8
-
Python
12
-
React Js
19
-
React Native
1
-
Redux
2
-
Rust Programming
15
-
SEO - Search Engine Optimization
1
-
Tailwind CSS
1
-
Typescript
10
-
Uncategorized
0
-
Vue JS
1
-
Windows Operating system
1
-
Woocommerce
1
-
WordPress Development
2
Tags
- Artificial Intelligence (AI)
- Bash Scripting
- Business
- C
- C Programming
- C-sharp programming
- C++
- Code Editor
- Computer Engineering
- CSS
- Data Structure and Algorithm
- Database
- Design pattern
- Express JS
- git
- Git Commands
- github
- HTML
- Java
- JavaScript
- Laravel
- Mathematics
- MongoDB
- Mysql
- Node JS
- PHP
- Programming
- Python
- React Js
- Redux
- Rust Programming Language
- SEO
- TypeScript
- Vue JS
- Windows terminal
- Woocommerce
- WordPress
- WordPress Plugin Development