Background image, using css [closed]

-1

How do I put a background image on div , using css?

I tried using single quotes but nothing happened:

background: url('images/html.jpg');

I'm doing so on:

#tudo { width: 100%; height: 992px; background: url('images/html.jpg');}
    
asked by anonymous 20.04.2014 / 20:46

2 answers

1

Try this:

<div style="background-image:url(images/html.jpg)">Conteúdo da div</div>

or

#tudo{
 background-image:url(images/html.jpg);
 width:100%;
 height:992px;
}
<div id="tudo">Conteúdo da div</div>
    
20.04.2014 / 21:28
0

For this there are 2 probable reasons:

  • The reported image (images / html.jpg) does not exist
  • You did not include CSS in the file.
  • The 1st can be solved by accessing the image if it exists so you did not include the CSS in the file try replacing the file code with the following:

    <style>
    #tudo {
      width: 100%;
      height: 992px;
      background-image: url(images/html.jpg);
    }
    </style>
    <div id="tudo"></div>
    

    As you can see through this link the code works.

        
    21.04.2014 / 14:55