Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Web Programming > CSS > CSS Cascading Style Sheets
CSS Cascading Style Sheets All issues relating to Cascading Style Sheets (CSS).
Welcome to the p2p.wrox.com Forums.

You are currently viewing the CSS Cascading Style Sheets section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old October 30th, 2009, 12:48 AM
Authorized User
Join Date: Jan 2004
Posts: 30
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to creative_eye
Default Background image in DIV not displaying

I've a image which I need to show as background in a DIV. Here is the code:

#inner_banner { background:url(images/inner-banner.jpg) no-repat; height:200px; display:block; width:950px; float:left; }

<div id="inner_banner">some text here</div>

But this code doesn't showing the background image (in all browsers), only blank space. What I'm doing wrong?
Old October 30th, 2009, 07:38 AM
Friend of Wrox
Join Date: May 2004
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts


<div id="inner_banner">some text here</div>

<div class="inner_banner">some text here</div>
Please check this link for more example:
Om Prakash Pant
Click the "Thanks" button if this post helped you.
Old October 30th, 2009, 09:04 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi om_prakash,

I don't see how that would fix the problem. Take a look at the selector:


It's an ID selector and thus you need the id=, not class=

The problem is with the no-repat. Change that to no-repeat and it should work...


Imar Spaanjaars
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
Old December 31st, 2009, 04:05 PM
Friend of Wrox
Join Date: Jun 2007
Posts: 477
Thanks: 10
Thanked 19 Times in 18 Posts

Originally Posted by om_prakash View Post

<div id="inner_banner">some text here</div>

<div class="inner_banner">some text here</div>
Imar hit the solution on the head. More generally, if you have an id="myId" the CSS syntax is...

#myId {
...style declarations...
If you have a class="myClass" the syntax uses a period...

.myClass {
...style declarations...
I'd say depending on the stylesheet that 30-50% of my style rules redefine tag styles, 40-60% style IDs, and the 10-30% redefine classes. These are workhorses of CSS. :)

Whatever you can do or dream you can, begin it. Boldness has genius, power and magic in it. Begin it now.
-Johann von Goethe

When Two Hearts Race... Both Win.
-Dove Chocolate Wrapper

Chroniclemaster1, Founder of www.EarthChronicle.com
A Growing History of our Planet, by our Planet, for our Planet.

Last edited by chroniclemaster1; December 31st, 2009 at 04:08 PM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
Help need fixed background on a scrollable div birthdayzoot CSS Cascading Style Sheets 3 June 20th, 2007 02:15 PM
Background Image problem in DIV tag. cumminsj CSS Cascading Style Sheets 6 September 15th, 2006 03:02 AM
displaying an image from file stream into an image sanjeet ADO.NET 0 September 23rd, 2005 10:28 AM
background image for <div> anshul CSS Cascading Style Sheets 4 May 16th, 2005 11:00 AM
line-height -n- background-color with <DIV> block anshul HTML Code Clinic 11 September 5th, 2004 02:15 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.