InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS properties

  • CSS3 flexbox
  • all
  • animation
  • background-color
  • background-image
  • border
  • border-color
  • border-radius
  • border-style
  • border-width
  • bottom
  • box-shadow
  • box-sizing
  • calc function
  • clip
  • color
  • color value currentColor
  • color values
  • cursor
  • float
  • font
  • font-family
  • font-size
  • font-style
  • font-variant
  • font-weight
  • generated content
  • left
  • letter-spacing
  • line-height
  • list-style
  • list-style-image
  • list-style-position
  • list-style-type
  • margin
  • max-height
  • max-width
  • min-height
  • min-width
  • opacity
  • outline
  • outline-color
  • outline-style
  • outline-width
  • overflow
  • padding
  • pointer-events
  • position
  • resize
  • right
  • text-align
  • text-decoration
  • text-indent
  • text-overflow
  • text-shadow
  • text-transform
  • top
  • transform
  • transition
  • transition-delay
  • transition-duration
  • transition-property
  • transition-timing-function
  • visibility
  • white-space
  • word-break
  • word-spacing
  • word-wrap/overflow-wrap
  • z-index
 
  • Home
  • > Tutorials
  • > CSS
  • > CSS properties

CSS color values

on Apr 1, 2016

CSS3 color values are used in many CSS properties like color, background-color, etc. CSS3 color values can be specified in many ways. Here is the list of various ways to specify color:

Format Description Examples
Predefined e.g. red, blue, orange
RGB hexadecimal # followed by 6 of 3 hex chars. 3 digit for #rgb is converted to #rrggbb by replicating digits #ff0000, #f00
RGB function notation rgb(integer, integer, integer) or RGB(percentage, percentage, percentage). Integer can be between 0 and 255. Percentage of 100% is equivalent to 255. rgb(255,0,0), rgb(100%, 0%, 0%)
RGBA function notation rgb(integer, integer, integer, alpha) or RGB(percentage, percentage, percentage, alpha). alpha can be between 0 and 1.0 rgb(255,0,0,1), rgb(100%,0%,0%,1)
transparent Can be considered a shorthand for transparent black, rgba(0,0,0,0) transparent
HSL value (hue, saturation, lightness). hue is between 0 and 360 (0 inclusive, 360 exclusive). saturation, lightness are in percentage. hsl(0, 100%, 50%) /*red*/
hsl(120, 100%, 25%) /*dark green*/
HSLA value (hue, saturation, lightness, alpha) hsla(240, 100%, 50%, 0.5) /* semi-transparent solid blue */

Examples – color values

In the following code, CSS property color can be changed to the following values
  • red
  • #00ff00
  • rgb(80%, 0%, 0%)
  • rgb(80%, 0%, 0%, 0.5)
  • transparent
  • hsl(0, 100%, 50%)
  • hsla(240, 100%, 50%, 0.5)
<style type="text/css">
.box {
  width: 100px; height: 100px;
  color:red;
}
</style>
<div class="box">
  Color of this text will change
</div>
color refresh done
try it online

Related

  • CSS color
  • CSS color value currentColor

Specification and Browser compatibility

SpecificationStatusCategories
CSS3 ColorsW3C RecommendationCSS3
Desktop
ChromeFirefoxIEEdgeSafariOpera
Yes 4+ Yes 3+ Yes 9+ Yes 12+ Yes 3.1+ Yes 10.0-10.1+
Mobile
Android ChromeAndroid FirefoxiOS SafariIE MobileOpera Mobile
Yes 47+ Yes 44+ Yes 3.2+ Yes 10+ Yes 10+
source: caniuse.com

Suggested posts:

  1. CSS border-width – set element border width of four sides
  2. CSS outline – create outline around an element
  3. How to detach Chrome developer tools window
  4. CSS color
  5. PHP – print array in one line
  6. jQuery – load a script with cache enabled
  7. Mac – open Finder from terminal – quick tip
  8. wget handy commands
Share this article: share on facebook share on linkedin tweet this submit to reddit
Posted in Tutorials | Tagged CSS, CSS properties, Tutorials
  • Browse content
  • Article Topics
  • Article archives
  • Contact Us
Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

Copyright © 2025 InfoHeap.

Powered by WordPress