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!
11 Answers
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)
-
-
@Ahsan: My window is very tall so removing the `` results in the image as posted by @thirtydot. – Sparky Jun 24 '11 at 17:24
-
html { height: 100% } and body { min-height: 100% } worked for me. Thank you! – rvaliev May 12 '16 at 20:44
-
-
this answer provides the perfect solution with simple explanation. thanks – Speedy11 Feb 25 '23 at 10:30
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:
<div id="dp_swf_engine" style="position: absolute; width: 1px; height: 1px;"></div>
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?!)
-
4The solution teaches us to debug rather than having spoonfed answer. – Shoaib Chikate Jun 19 '15 at 11:22
-
2
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.

- 4,305
- 1
- 20
- 25
-
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+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
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..

- 6,680
- 7
- 55
- 80
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'.

- 27
- 5

- 70,219
- 68
- 205
- 290
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.

- 12,126
- 5
- 38
- 52
There is a second paragraph in your footer that contains a script. It is this that is causing the issue.

- 15,460
- 11
- 57
- 87
-
-
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
-
-
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
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.

- 5,465
- 2
- 21
- 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
-
-
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
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.

- 824
- 2
- 9
- 18
(class/ID):after {
content:none;
}
Always works for me class or ID can be for a div or even body causing the white space.

- 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.

- 50,140
- 28
- 121
- 140

- 99
- 1
- 10
` tags around the `
– Sparky Jun 24 '11 at 17:32