Adding a background image to a <div> element

Sandeep picture Sandeep · Apr 9, 2011 · Viewed 883.3k times · Source

Is it possible to make a <div> element contain a background image, and if so, how would I go about doing this?

Answer

phoibos picture phoibos · Apr 9, 2011

You mean this?

<style type="text/css">
.bgimg {
    background-image: url('../images/divbg.png');
}
</style>

...

<div class="bgimg">
    div with background
</div>