RBT
RBT

Reputation: 25887

How to set CSS RGB colors using numeric values?

I'm in new to HTML/CSS. I can see that there are various ways of setting color code in a CSS style description i.e. by name e.g. yellow or by hex code #ffff00. I see there are also numeric equivalents of each color e.g. yellow has numeric equivalent as 255,255,0 but applying the below style on my body element has no effect at all:

My CSS:

body {
background-color: 255,255,0;
color: black !important;
}

Can someone help me on this?

Upvotes: 3

Views: 6534

Answers (4)

دواس دواس
دواس دواس

Reputation: 11

.body {
background-color: rgb(255,255,0);
color: black !important;
padding:25px;
}
<div class="body"></div>

Upvotes: 1

Zaid Bin Khalid
Zaid Bin Khalid

Reputation: 763

rgba(255,255,0,1) To add opacity, use rgba. Where 1 is 100% opacity.

.body {
background-color: rgb(255,255,0);
color: black !important;
padding:25px;
}
<div class="body"></div>

Upvotes: 2

alessandrio
alessandrio

Reputation: 4370

you need to add this rule to your css rgb(0,0,0) or rgba(0,0,0,0.5) to opacity.

body {
    background-color: rgb(255,255,0);
    color: rgba(0,0,0,0.7);
}

Upvotes: 2

Carl Binalla
Carl Binalla

Reputation: 5401

Like this

body {
    background-color: rgb(255,255,0);
}

To add opacity, use rgba. Where 1 is 100% opacity.

body {
    background-color: rgba(255,255,0, 1);
}

Upvotes: 7

Related Questions