How do websites get this almost white color?


The background of a lot of websites is not actually white: it's more of a greyish color:

enter image description here

How do they do this? Is it just a picture they made or is there some CSS?


Answers:


Short answer: Picture and CSS: both are possible.

Long answer:

To add a background image, you will have to do something like

body {
    background-image: url('bgpic.png');
    }

where bgpic.png is the image that you want to use as a background.

I believe using a background image for a simple background as this one will only increase your loading time, and in turn, frustrate your users. The CSS alternative is faster and easier, as you might have probably guessed from the other answers.

In CSS, you can style your background like this:

body {
    background-color: #efefef;
    }

Or, as someone pointed out, use the rgb equivalent:

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

And might I add that it is also possible to specify the transparency of the background. Say, you have a background picture, and you have a <div class="foo"> that could use a semi-transparent background; then you would do something like:

body {
    background-image: url('bgpic.png');
    }

.foo {
    background-color: rgba(0, 0, 0, .5);
    }

Notice that the last value given to rgba is the % transparency that you want. It is a value less than 1.

Here's a JSFIDDLE.