loading

Colors

Color, Rgb, Hex, Hsl, Rgba, Hsla, Css Color Names, Background Color, Text Color, Border Color

RGB, HEX, HSL, RGBA, and HSLA values, as well as established color names, are used to specify colors.


CSS Color Names

A preset color name can be used in CSS to specify a color:

Tomato
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
LightGray

CSS Background Color

HTML components have background color settings:

Hello World

Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

Example

				
					<h1 style="background-color:DodgerBlue;">Hello World</h1>
<p style="background-color:Tomato;">Lorem ipsum...</p>
				
			

CSS Text Color

You can set the color of text:

Hello World

This is line

This is text

Example

				
					<h1 style="color:Tomato;">Hello World</h1>
<p style="color:DodgerBlue;">Lorem ipsum...</p>
<p style="color:MediumSeaGreen;">Ut wisi enim...</p>
				
			

CSS Border Color

You can set the color of borders:

Hello World

Hello World

Hello World

Example

				
					<h1 style="border:2px solid Tomato;">Hello World</h1>
<h1 style="border:2px solid DodgerBlue;">Hello World</h1>
<h1 style="border:2px solid Violet;">Hello World</h1>
				
			

CSS Color Values

Additionally, RGB, HEX, HSL, RGBA, and HSLA values can be used in CSS to specify colors:

Similar to the color “Red”:

rgb(255, 99, 71)
#ff6347
hsl(9, 100%, 64%)

Same as color name “Red”, but 50% transparent:

rgba(255, 99, 71, 0.5)
hsla(9, 100%, 64%, 0.5)

Example

				
					<h1 style="background-color:rgb(255, 99, 71);">...</h1>
<h1 style="background-color:#ff6347;">...</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">...</h1>

<h1 style="background-color:rgba(255, 99, 71, 0.5);">...</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">...</h1>
				
			

colors 

RGB 

HEX 

HSL 

RGBA 

HSLA 

CSS color names 

background color 

text color 

border color

HTML

HTML5

HTML tutorials
Learn HTML
Free HTML tutorials
HTML Example
HTML Explained

CSS Colors: Mastering the Fundamentals

In the world of web design, color is a fundamental element that can make or break the visual appeal of a website. In CSS, there are several ways to define and apply colors, each with its own unique properties and use cases. In this section, we’ll explore the different color models and how to effectively utilize them in your CSS code.

Colors in CSS can be specified using various formats, including RGB (Red, Green, Blue), HEX (Hexadecimal), HSL (Hue, Saturation, Lightness), and their respective alpha channel counterparts, RGBA and HSLA. Additionally, CSS provides a set of predefined color names that can be used for quick and easy color selection.

Understanding the different color models and their applications is crucial for creating visually stunning and consistent designs. Whether you’re setting the background color, text color, or border color, mastering CSS colors will empower you to bring your web projects to life.

In any CSS course, understanding color is a fundamental topic. CSS provides several ways to specify colors, each with its own advantages and use cases.

The most common color models used in CSS are RGB (Red, Green, Blue) and HSL (Hue, Saturation, Lightness). RGB values can be specified as integers between 0-255 (e.g., rgb(255, 0, 0) for red) or as hexadecimal values (e.g., #FF0000 for red). HSL values define color by hue (0-360 degrees), saturation (0-100%), and lightness (0-100%).

CSS also supports the use of named colors, which are a predefined set of colors with recognizable names like “red”, “blue”, and “chartreuse”. These can be convenient for quick color selection but offer limited options compared to the numeric color models.

In addition to basic colors, CSS supports alpha transparency using the RGBA and HSLA color models. These allow you to specify an alpha channel (opacity) value between 0 (fully transparent) and 1 (fully opaque).

Colors in CSS can be applied to various elements, such as backgrounds, text, and borders. Understanding how to effectively use color in your CSS can greatly enhance the visual appeal and usability of your web designs.

CSS Colors: Mastering the Fundamentals

In the world of web design, color is a crucial element that can make or break the visual appeal of a website. In CSS, there are several ways to define and apply colors, each with its own unique characteristics and use cases. In this section, we’ll explore the different color models and how to effectively utilize them in your CSS course.

Colors in CSS can be specified using various formats, including RGB (Red, Green, Blue), HEX (Hexadecimal), HSL (Hue, Saturation, Lightness), and their respective alpha (transparency) counterparts, RGBA and HSLA. Additionally, CSS provides a set of predefined color names that can be used for quick and easy color selection.

When working with colors in CSS, you can apply them to various elements, such as the background, text, and borders. Understanding the different color models and their applications will empower you to create visually stunning and harmonious designs.

By the end of this section, you’ll have a comprehensive understanding of CSS colors and be able to confidently use them to enhance the aesthetics of your web projects.

 

Share this Doc

Colors

Or copy link

Explore Topic