CSS color units
Color units
The value of color can be a color name (keyword), a RGB value or a hexadecimal value. We will see an example using the same color but specified in different ways.
Here is the css file (say color-unit.css):
p {
color: olive
}
li {
color: #808000
}
a: link {
color: rgb(128,128,0)
}
This stylesheet specifies same color in three different ways (color name, hex value and rgb value ).
Here is the html file (say color-unit.htm) to which the stylesheet above is applied:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title>example of external CSS - color property </title>
<link href="color-unit.css" rel="stylesheet" type="text/css" />
</head>
<body>
<p>We are learning color property of CSS</p>
<ul>
<li>we will learn color property of CSS in this section</li>
</ul>
<a href="#">Click here to learn more</a>
</body>
</html>
Here is how it will look:
Before go in more detail about css color property,in the next page we will see different ways of specifying color
View this example of CSS color unit in a different browser window
Previous: CSS (foreground) color
Next:
CSS color inherit
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework