37

I am unable to get the white space at the bottom of this page to disappear. I have both min-height and height tags in body. Any suggestions? Thanks!

http://womancareolympia.webs.com/

Filip De Vos
  • 10,918
  • 1
  • 45
  • 59
Jedediah Shumaker
  • 419
  • 1
  • 5
  • 7
  • 1
    You need to [validate your HTML](http://validator.w3.org/check?uri=http%3A%2F%2Fwomancareolympia.webs.com%2F&charset=%28detect+automatically%29&doctype=Inline&group=0) for one thing. And secondly, your CSS is a total disaster. You have a CSS sheet being imported by a CSS sheet that's being imported by your main external CSS sheet... and all three are trying to style the same main elements differently... it seems pointless and makes it difficult to troubleshoot. – Sparky Jun 24 '11 at 16:39
  • Yep, I am being forced to use an editor and can only ADD my own CSS to the existing. – Jedediah Shumaker Jun 24 '11 at 16:45
  • @Jedediah: I'm not sure how being forced to use an editor prevents you from editing anything you want within your HTML file. You could simply remove all the external CSS and replace with one CSS file of your own creation, no? – Sparky Jun 24 '11 at 17:00
  • Nope. It is an online editor and everything is generated. I can add my own CSS. That's it. Period. It sucks hard. – Jedediah Shumaker Jun 24 '11 at 17:06
  • 1
    @Jedediah Shumaker: Be sure to look at the second part of my answer. – thirtydot Jun 24 '11 at 17:14
  • 2
    @Jedediah: The second part of the @thirtydot answer also explains why some people thought they solved the problem by removing the `

    ` tags around the `

    – Sparky Jun 24 '11 at 17:32
  • @Jedediah: The taller I make the window, the longer the scroll-bars and scrolling area becomes. Weird. – Sparky Jun 24 '11 at 17:47

11 Answers11

75

I find it quite remarkable that out of 6 answers, none of them have mentioned the real source of the problem.

Collapsing margins on the last p inside #fw-footer is where that extra space is originating from.

A sensible fix would be to add overflow: hidden to #fw-footer (or simply add margin: 0 on the last p).

You could also just move the script inside that last p outside of the p, and then remove the p entirely; there's no need to wrap a script in a p. The first p (#fw-foottext) has margin: 0 applied, so the problem won't happen with that one.


As an aside, you've broken the fix I gave you in this question:

CSS3 gradient background with unwanted white space at bottom

You need html { height: 100% } and body { min-height: 100% }.

At the moment, you have html { height: auto } being applied, which does not work:

(This happens with a window taller than the content on the page)

Community
  • 1
  • 1
thirtydot
  • 210,355
  • 44
  • 377
  • 337
31

The problem is how 100% height is being calculated. Two ways to deal with this.

Add 20px to the body padding-bottom

body {
    padding-bottom: 20px;
}

or add a transparent border to body

body {
    border: 1px solid transparent;
}

Both worked for me in firebug

In defense of this answer

Below are some comments regarding the correctness of my answer to this question. These kinds of discussions are exactly why stackoverflow is so great. Many different people have different opinions on how best to solve the problem. I've learned some incredible coding style that I would not have thought of myself. And I've been told that readers have learned something from my style from time to time. Social coding has really encouraged me to be a better programmer.

Social coding can, at times, be disturbing. I hate it when I spend 30 minutes flushing out an answer with a jsfiddle and detailed explanation only to submit and find 10 other answers all saying the same thing in less detail. And the author accepts someone else's answer. How frustrating! I think that this has happend to my fellow contributors–in particular thirtydot.

Thirtydot's answer is completely legit. The p around the script is the culprit in this problem. Remove it and the space goes away. It also is a good answer to this question.

But why? Shouldn't the p tag's height, padding and margin be calculated into the height of the body?

And it is! If you remove the padding-bottom style that I've suggested and then set the body's background to black, you will see that the body's height includes this extra p space accurately (you see the strip at the bottom turn to black). But the gradient fails to include it when finding where to start. This is the real problem.

The two solutions that I've offered are ways to tell the browser to calculate the gradient properly. In fact, the padding-bottom could just be 1px. The value isn't important, but the setting is. It makes the browser take a look at where the body ends. Setting the border will have the same effect.

In my opinion, a padding setting of 20px looks the best for this page and that is why I answered it this way. It is addressing the problem of where the gradient starts.

Now, if I were building this page. I would have avoided wrapping the script in a p tag. But I must assume that author of the page either can't change it or has a good reason for putting it in there. I don't know what that script does. Will it write something that needs a p tag? Again, I would avoid this practice and it is fine to question its presence, but also I accept that there are cases where it must be there.

My hope in writing this "defense" is that the people who marked down this answer might consider that decision. My answer is thought out, purposeful, and relevant. The author thought so. However, in this social environment, I respect that you disagree and have a right to degrade my answer. I just hope that your choice is motivated by disagreement with my answer and not that author chose mine over yours.

natedavisolds
  • 4,148
  • 1
  • 16
  • 23
  • This is not the solution, You have defined `

    ` in footer containing script. Remove the `

    ` it's taking space. As I have mentioned in my answer.
    – Ahsan Rathod Jun 24 '11 at 16:47
  • @Ahsan: I tested the OP's actual HTML code in an offline file, removal of `

    ` tags and `
    – Sparky Jun 24 '11 at 16:52
  • I agree with @Ahsan, this is not the solution. See answer by @thirtydot instead. – Sparky Jun 24 '11 at 18:11
  • @ahsan @Sparky672 please see my defense above as an explanation of this answer. – natedavisolds Jun 25 '11 at 19:20
  • Good defense but your way of fixing is informative and a hack or a diversion. – Ahsan Rathod Jun 25 '11 at 19:44
  • @ahsan - I can't fix that the browser isn't calculating the gradient correctly! We can either help it or avoid it. – natedavisolds Jun 25 '11 at 20:22
  • +1 for the addendum. I simply didn't come across this question until 6 answers of varying quality had already been posted. Your answer does work just fine, it's just missing the knowledge of *why* it works. If a future reader wants that information, they can look at my answer :) – thirtydot Jun 27 '11 at 22:37
25

I had white space at the bottom of all my websites; this is how I solved the matter:

the first and best thing you can do when you are debugging css issues like this is to add:

*{ border: 1px solid red; }

this css line puts a red box around all your css elements.

I had white space at the bottom of my page due to a faulty chrome extension which was adding the div 'dp_swf_engine' to the bottom of my page:

without the red box, I would have never noticed a 1px div. I then got rid of the faulty extension, and put 'display:none' on #dp_swf_engine as a secondary measure. (who knows when it could come back to add random white space at the bottom of my page for all my pages and apps?!)

B Cronyn
  • 637
  • 8
  • 13
2

Try setting the height of the html element to 100% as well.

html {
    min-height: 100%;
    overflow-y: scroll;
}    
body {
     min-height: 100%;
}

Reference from this answer..

yu yang Jian
  • 5,003
  • 3
  • 42
  • 65
1

The problem is the background image on the html element. You appear to have set it to "null" which is not valid. Try removing that CSS rule entirely, or at least setting background-image:none

EDIT: the CSS file says it is "generated" so I don't know exactly what you will be able to edit. The problem is this line:

html {
    background-color: null !important;
    background-position: null !important;
    background-repeat: repeat !important;
    background-image: url('http://images.freewebs.com/Images/null.gif') !important;
}

I'm guessing you've put null as a value and it has set the background to a GIF called 'null'.

sRaviolii
  • 17
  • 4
DisgruntledGoat
  • 62,693
  • 62
  • 192
  • 281
1

This will remove the margin and padding from your page elements, since there is a paragraph with a script inside that is causing an added margin. this way you should reset it and then you can style the other elements of your page, or you could give that paragraph an id and set margin to zero only for it.

<style>
* {
   margin: 0;
   padding: 0;
}
</style>

Try to put this as the first style.

Jose Faeti
  • 11,379
  • 5
  • 37
  • 52
0

There is a second paragraph in your footer that contains a script. It is this that is causing the issue.

shanethehat
  • 15,105
  • 10
  • 54
  • 84
  • While semantically sloppy to put a ` – Sparky Jun 24 '11 at 16:30
  • It wasn't the semantics I was referring to, but the existence of that particular script. Its removal cures the problem. – shanethehat Jun 24 '11 at 16:40
  • I tested this myself (Safari) and removal of the scripts made no difference whatsoever. – Sparky Jun 24 '11 at 16:44
  • Did you also remove the containing paragraph? that's what fixed it for me in Firebug. – shanethehat Jun 24 '11 at 16:46
  • Yes, the `

    ` tags were removed first and then the `
    – Sparky Jun 24 '11 at 16:52
  • I see the solution and agree with it (hence voting it), but that doesn't alter the fact that using the supplied link in FF4 Win, removing the second

    and its contents from the footer made the page display correctly. However I can offer no suggestion as to why, other than Firebug was in error somehow.

    – shanethehat Jun 24 '11 at 17:01
  • @Sparky672: Simply removing the `p` around the `script` will resolve the problem. I've overridden the `body { padding-bottom: 20px; }` fix in these two demos. With `p`: http://jsbin.com/uqored. Without `p`: http://jsbin.com/uqored/2 *(and make sure your window is not very tall, or you'll see whitespace for reason in the second part of my answer)* – thirtydot Jun 24 '11 at 17:19
  • @shanethehat: My window is tall so that's probably why. I think the accepted answer is a bit of a hack though. See answer posted by @thirtydot... it's the real answer. – Sparky Jun 24 '11 at 17:22
  • @everyone - I've updated my answer with why I think it is the correct answer. The p tag containing the script is the culprit, but the browser isn't calculating where to start the gradient correctly. – natedavisolds Jun 25 '11 at 19:23
0

It is happening Due to:

<p><script>var _nwls=[];if(window.jQuery&&window.jQuery.find){_nwls=jQuery.find(".fw_link_newWindow");}else{if(document.getElementsByClassName){_nwls=document.getElementsByClassName("fw_link_newWindow");}else{if(document.querySelectorAll){_nwls=document.querySelectorAll(".fw_link_newWindow");}else{document.write('<scr'+'ipt src="http://static.websimages.com/static/global/js/sizzle/sizzle.min.js"><\/scr'+'ipt>');if(window.Sizzle){_nwls=Sizzle(".fw_link_newWindow");}}}}var numlinks=_nwls.length;for(var i=0;i<numlinks;i++){_nwls[i].target="_blank";}</script></p>

Remove <p></p> around the script.

Ahsan Rathod
  • 5,291
  • 2
  • 18
  • 25
  • Removing comments cannot ever make a difference to a HTML page, since they are stripped out by the browser. – DisgruntledGoat Jun 24 '11 at 16:30
  • The script is the cause for the white space – Ahsan Rathod Jun 24 '11 at 16:33
  • I tested this myself (Safari) and removal of the scripts made no difference whatsoever. – Sparky Jun 24 '11 at 16:46
  • Not removal of script, i said removal of `

    ` tag. it is taking spaces.
    – Ahsan Rathod Jun 24 '11 at 16:49
  • @Ahsan: Previously you said, _"The script is the cause for the white space"_ and now you say, _"Not removal of script"_... **It makes NO difference** because I removed them both. – Sparky Jun 24 '11 at 16:54
  • I Tested it in firefox by saving the page and by firebug. And it is the cause. – Ahsan Rathod Jun 24 '11 at 16:58
  • @Sparky672: My answer explains what's actually going on here, if you're interested. – thirtydot Jun 24 '11 at 17:00
  • @Ahsan: If it means anything, while I couldn't reproduce your solution, I don't like the accepted answer either... it seems like a hack. – Sparky Jun 24 '11 at 17:06
  • @thirtydot: I don't understand why the problem didn't just go away when I removed the `

    ` and its contents? But thank-you for the detailed explanation... your posts are always informative and educational.
    – Sparky Jun 24 '11 at 17:12
  • @thirtydot and @Ahsan: I have a huge monitor and thirtydot's answer explains fully why I could not see any improvement after removing the `

    ` and its contents.
    – Sparky Jun 24 '11 at 17:28
0

I had the same problem when parsing html to string. Removing the last <p></p> (and replacing it with an alternative if desirable, like < /br>) solved it for me.

Joakim Sjöstedt
  • 406
  • 1
  • 5
  • 13
0
(class/ID):after {
content:none;
}

Always works for me class or ID can be for a div or even body causing the white space.

Rachel
  • 1
-1

I faced this issue because my web page was zoomed out to 90% and as I was viewing my page in responsive mode through the browser developer tools, I did not notice it right away.

Bhargav Rao
  • 41,091
  • 27
  • 112
  • 129