Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

rgb

Description

The rgb function for CSS specifies red, green, and blue.

ChannelLow UnitHigh UnitLow NumberHigh Number
r0.0%100.0%0.0255.0
g0.0%100.0%0.0255.0
b0.0%100.0%0.0255.0
a0.0%100.0%0.01.0

Syntax

CSS

rgb()

Values

<rgb()> =
    [ <legacy-rgb-syntax> | <modern-rgb-syntax> ]
<legacy-rgb-syntax> =
    rgb(
        <percentage>#{3},
        <alpha-value>?
    ) |
    rgb(
        <number>#{3},
        <alpha-value>?
    )
<percentage>

Specifies the percentage using a number followed by a percent sign (%).

<alpha-value> =
    <number> |
    <percentage>
<number>

An integer or zero or more decimal digits followed by a dot (.) followed by one or more decimal digits. The first character may be preceded by a sign (- or +). The last character may be succeeded by an exponent (e or E) and an integer.

<percentage>

Specifies the percentage using a number followed by a percent sign (%).

<number>

An integer or zero or more decimal digits followed by a dot (.) followed by one or more decimal digits. The first character may be preceded by a sign (- or +). The last character may be succeeded by an exponent (e or E) and an integer.

<modern-rgb-syntax> =
    rgb(
        [ <number> | <percentage> | none ]{3}
        [ / [ <alpha-value> | none ] ]?
    )
<number>

An integer or zero or more decimal digits followed by a dot (.) followed by one or more decimal digits. The first character may be preceded by a sign (- or +). The last character may be succeeded by an exponent (e or E) and an integer.

<percentage>

Specifies the percentage using a number followed by a percent sign (%).

none

Specifies a missing component.

<alpha-value> =
    <number> |
    <percentage>
<number>

An integer or zero or more decimal digits followed by a dot (.) followed by one or more decimal digits. The first character may be preceded by a sign (- or +). The last character may be succeeded by an exponent (e or E) and an integer.

<percentage>

Specifies the percentage using a number followed by a percent sign (%).

Examples

1 · legacy · rgb · unit

2 · legacy · rgba · unit

3 · legacy · rgb · number

4 · legacy · rgba · number

5 · modern · rgb · unit

6 · modern · rgba · unit

7 · modern · rgb · number

8 · modern · rgba · number

9 · JS

color

hsl

hsla

hwb

lab

lch

oklab

oklch

rgba

abs

acos

asin

atan

atan2

attr

calc

clamp

color

conic-gradient

cos

counter

counters

hsl

hsla

hwb

lab

lch

linear-gradient

matrix

matrix3d

max

min

mod

oklab

oklch

param

perspective

radial-gradient

rem

repeating-conic-gradient

repeating-linear-gradient

repeating-radial-gradient

rgba

rotate

rotate3d

rotateX

rotateY

rotateZ

round

scale

scale3d

scaleX

scaleY

scaleZ

sin

skew

skewX

skewY

src

tan

translate

translate3d

translateX

translateY

translateZ

url

var

World Wide Web Consortium (W3C)

HomeMenu