Hello
I have been creating some web sites using CSS lately and I think I almost have a grasp on it until I preview it in Firefox. The page looks the way I want it to in IE6 but Firefox always has spaces around images.

here are 2 web sites that I have the exact same issue with
any help would be great

the css for this site is here


and

the css is included in the source for this page


Thanks
Mark

Dani AI

Generated

A few pixels of apparent “spacing” under or between images in Firefox usually comes from how images are treated as inline content and how the browser builds the line box. The thread shows the practical result: resetting image defaults (as applied by ) together with removing the line-box height (the tip from @GCS584) resolves most visible gaps. That combination addresses both default margins/borders and the small baseline/line-height space that browsers reserve for text descenders.

Root causes and concise alternatives:

  • Images are inline by default and sit on the text baseline, which can leave a thin gap below them. Making layout images block-level avoids baseline spacing.
  • Adjacent inline images can show small horizontal gaps caused by whitespace in the HTML; that can be eliminated by removing the whitespace or by zeroing the parent font-size for that image row.
  • Setting vertical alignment (for inline images) or explicitly floating images changes how the line box is computed. Deprecated attributes like hspace/vspace should be replaced with CSS padding.

Quick troubleshooting checklist (applies to nav bars, tiled graphics and stacked images):

  • Confirm a standards DOCTYPE so browsers use the same box rules.
  • Reset browser defaults (body margin/padding and image margins/borders).
  • For images used purely for layout, prefer block-level (or floated) images; for inline icon rows, remove HTML whitespace or set the parent container’s font-size to zero and restore text size where needed.
  • Avoid unnecessary fixed container heights; use clearing/clearfix patterns when floats are used.
  • Re-validate HTML/CSS and test in Firefox and the target IE versions.

Credit to and @GCS584 for the fixes noted in the thread. For longer-term maintainability, prefer CSS layout techniques (floats, flexbox or grid) and treat images as content, not as spacing, wherever possible.

Recommended Answers

All 13 Replies

Member Avatar for Member #114696

Have you tried putting padding, margin and all to 0.

commented: very willing to help, thanks +1

When i look at your site in ff I can't see any problems, unless you want your text to be touching your images. I have attached as screen shot (poor quality but you get the point) of what your site looks like in the latest version of ff. But as vishesh said you could do something like

img   {padding:0;
          margin:0;
          border:0;}

BTW.. Has anyone else noticed that alot of churches have really decent websites?


Also on plexus2007 you need to decrease the width of the header circle images or take one away because they are too wide for the rest of your content.

Hey, Thanks a lot for the suggestions. I tried adding

img {padding:0;
     margin:0;
     border:0;
}
#container {
width : 780px; 
height : auto;
margin-right : auto; 
margin-left : auto;
padding:0;
margin:0;
border:0;
} 
#cantainer img {
padding:0;
     margin:0;
     border:0;
  }

but it still has the breaks.
all those white lines in the screen shot around the nav are not suppose to be there, as well there is a break in the tower. if you view it in IE those white lines are not there and the tower doesn't have a break in it. any other suggestion, I really appreciate the help.
Mark

You may want to set the height of all of your image containers. I am not sure whether it will fix it but its worth a try.

Hey, thanks, that took one of the spaces away but not all of them, I only had a chance to try it on the so i'll see what it does with the other one...also, the site isn't centered in firefox...Thanks again for all your help

You may need to set all the margins and padding and borders of the main content as well. This may help.

I set every image to have
hspace="0" vspace="0" border="0" is that what I was suppose to do?
sorry, im still kind of new to some of this.
once again though, I can't thank you enough for the help

no every image should be like this

img { 
padding: 0;
margin: 0;
border: 0;
}

You then need to set each images height and width. You also need to set the border, margin of all of your content to 0 if you don't want any. You may want to check your html to make sure there is no formatting in it.

(if you like the help why not give my rep a tickle ;) )

commented: always willing to help and give great suggestion time after time. Thanks +1

I tried that, I completely cleaned up the css and html and validated it with no errors or warnings...and I still can't figure out why it's not centered as well.

I did change the background colours and the space just above the content if a sace between the nav and the content so it's showing the container. the spaces in the nav itself is the nav background (if that makes sense.

I think I have almost sorted it for you but I cannot get rid of one of the gaps. You need to use the following css (please make a backup of your old one first):

body {
    font-family : Verdana, Arial, Helvetica, sans-serif;
    font-size : 12px;
    color : #186565;
    background-color : #fff;
    background-image:url(images/bg.gif);
    letter-spacing:1px;    
    border:0;
    

} 
#nav img { 
padding: 0;
margin: 0;
border: 0;
}
body, td, th {
color : #000000;    
}
a:link {
    color: #000000;
}
a:visited {
    color: #000000;
}
a:hover {
    color: #A06047;
}
a:active {
    color: #000000;
}
#container {
width : 780px; 
height : 726px;
margin-right : auto; 
margin-left : auto;
} 
#banner {
width:780px;
height:130px;
background-color:#C1D4FF;    
padding: 0px;
border: 0px;
margin: 0px;
}
#nav {
width:780px; 
height: 78px;
border-width: 0px;
margin: 0px;
padding: 0px;
margin-bottom: 0px;
background-color:#C1D4FF;
line-height: 0px;
}
#content {
height:450px; 
width : 780px;
padding:0;
margin-top: 0px;

border-width: 0px;
background-repeat:no-repeat; 
background-color:#C1D4FF;
background-image:url(images/contentbg.gif);
} 
#content img {
float:right; 
padding: 0;
margin: 0;
border: 0;
}
#pics {
width:350px;
height:225px;
float:left;
padding:3px;
}
#pics img {
padding-right:5px;
padding-bottom:5px;
float:left; 
padding: 0;
margin: 0;
border: 0;
}
#footer {
height:30px; 
width : 780px;
padding:2px;
background-color:#C1D4FF;

} 
#footer img { 
padding: 0;
margin: 0;
border: 0;
}
.style1 {
    font-size: 18px;
    font-weight: bold;
}
h1 {
font-family:"Times New Roman", Times, serif;
font-weight:bold;
font-size:24px;
}
img {
padding: 0px;
margin: 0px;
border-width: 0px;

}

Hope that helps

commented: good help(iamthwee) +6
Member Avatar for Member #114857

Hi,

I often have vertical spaces between two div's. Often what I end up using is:

line-height: 0;

I've taken a quick look at the code of the different sites mentioned, and it seems that the above css should fix it (if you apply it to the DIV).

Regards,

GCS584

[EDIT:] I don't have/use IE so, it's difficult for me to tell which spaces you're talking about :P

commented: It provided the final resolution, thanks so much +1

between roryt's code change and gcs584's suggestion both sites are displaying beautifully.. Thanks so much to all who helped, I only hope I can somehow return the favour in the future...
Take care
Mark

PS you are both going to get a rep nod right now

very glad we could help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.