Background image not appearing HTML CSS

user2615699 picture user2615699 · Aug 22, 2013 · Viewed 43k times · Source

I am new to html/css and I do not understand why my background image is not showing up. This is part of a simple test CSS sheet and HTML code for a simple site. I am trying to add a background-image and I have done this once and it worked and I do not know why it does not work now.

body{
background: url (rio.jpg); 
background-size: cover; 
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover; 
}

This is part of my css sheet. THe url works, I have used it for another trial site before. And my html is just a regular html document with a body etc..

Answer

Eric Kidd picture Eric Kidd · Aug 22, 2013

CSS is picky about functions.

You can't have a space after 'url' and the parenthesis.

Correct: background: url(path/to/image.jpg);

Incorrect: background: url (path/to/image.jpg);

Here's a fiddle demonstrating: http://jsfiddle.net/tJmmn/