Learn
Visual Rules
Color and Background Color
Color is an essential part of visual design and styling. You can use colors to set the mood of your web page and grab the attention of your users. Let's discuss some ways you can use colors in your CSS code.
Setting Text Color
You can set the text color of an HTML element using the color
property in CSS. The value of the property can be any valid CSS color.
You can also set the color of multiple elements at once by using a class or an ID, or by selecting all elements of a specific type.
Setting Background Color
You can set the background color of an HTML element using the background-color
property in CSS. The value of the property can be any valid CSS color.
You can also set the background color of multiple elements at once by using a class or an ID, or by selecting all elements of a specific type.
Using RGBA Colors
RGBA colors allow you to set the color of an element while also controlling its opacity. The rgba()
function uses four values: red, green, blue, and alpha (opacity). The red, green, and blue values are expressed as numbers between 0 and 255, while the alpha value is expressed as a number between 0 and 1.
Using Color Names
CSS has a number of predefined color names that you can use instead of specifying the color using an RGB or hex value. Some of the most common color names include red
, green
, blue
, yellow
, black
, and white
.
Remember, you want to choose colors that evoke the emotions you want in your users. Use color creatively to leave a lasting impression on your audience.
Instructions
Change the background color of the body to rgba(255, 0, 0, 0.5)
.
Change the text color of the table
element to #fff
.
Sign up to start coding
Already have an account?
Sign In