Search code examples
htmlcssclassbackgroundstylesheet

Background Image in CSS Class inside to <div>


I am new at web design and I have a question to ask. I can not see background image in . Here is my code. What am I doing wrong? I am sure that image is in the right location and I linked style.css to my html code.

PHP:

<div style="main_div">
<div style="banner">


</div><!--banner end-->
</div><!--main end-->

CSS:

.main_div{width: 1000px; margin: auto;}

.banner{
width:100%; 
height:100%;
background-image: url(../img/bannerimg.png); 
margin-top:50px;}

I also have reset code of Eric Meyer in CSS code. Thanks in advance.


Solution

  • you should change the style to class and it should work. your problem is that you are working with the wrong keyword.

    • class is to identify elements
    • id is to identify a unique element
    • style is to write CSS in the element