Hey all, just looking for a little bit of help with my webpage. I have finished off my first, but cannot get rid of a large area of white space at the bottom of the page.

When I view with Chrome and inspect element, it says that there is a "<a href="#"> in the area which I guess is creating the whitespace. I have spent an hour looking through the HTML to find an extra href but with no joy.

Can someone tell me where I'm going wrong? I have also tried to set a height for the body, but this doesnt seem to have any effect. My HTML is:

Aslo, I'm not sure if it's wrong as such, but I'd recommend leaving a space at leach end of your HTML comments. So this:

<!-- TOP NAVIGATION -->

instead of this:

<!--| TOP NAVIGATION |-->

JohnoLFC
—
2013-03-17T13:49:34Z —
#3

Thanks for that Ralph

I have cleared up those errors you have highlighted and the href has also now gone,

The white area is still showing to the right and bottom of my page. Could this be because the height and width are only 696px & 1400px? Is it the browser just filling up the rest of the screen?

Cheers

PaulOB
—
2013-03-17T15:47:46Z —
#4

JohnoLFC said:

. Could this be because the height and width are only 696px & 1400px? Is it the browser just filling up the rest of the screen?

Hi,

We'd need to see the CSS that goes with that html to help with your problem

If you have a gap at the bottom of the page the its either an element/property taking up space on the page or your viewport is taller than your content. We'd need to see the css or preferably a working link to debug further but it sounds as though you are expecting something to happen that is not quite normal. You shouldn't really be setting heights for your layout as its usually the content that dictates the height and you never really know how tall that content will be because users may have different set ups for their font-sizes and fonts etc.

JohnoLFC
—
2013-03-17T15:57:43Z —
#5

Thanks for the reply Paul,

Here is the website, you'll notice there is alot of white space to the right and bottom,

The white space at the bottom is because you have moved elements upwards using relative positioning but relative positioning does not alter the flow of the page (unlike margins). The big gap is where the elements would reside had position:relative not been applied. Position:relative only moves things visually but not physically and isn't meant for structural layout in the way that you have used it. An element moved with position relative leaves "gaps" in the page where the element originally lived and to all intents and purposes all elements on the page react as if the element was in its original position. The original position a relative element occupies is always preserved.

Suffice to say you should not use relative positioning for structural changes like that but rather use margins, floats or absolute positioning where necessary but absolute positioning should only be used in small doses or in places where the flow of the page is already preserved.

I'm not sure why you have sliced the whole top image into multiple images as you could have simply placed the whole image in one go (apart from the logo,nav and header text which should be in their own elements). That would save loads of div and loads of silly positioning and rids the html of mark up that shouldn't be there. Html is all about content and CSS the presentation so keep them as separate as possible.

I would have placed the whole top header section as a single background image but would have removed the logo, nav and header text. That lets you start the page with an h1 for the logo and the text Wooton primary school. No need for any special positioning apart from a few margins to nudge it into position Then you could follow with the nav which again would only need margins to nudge it into position and then float the menu items.

The sitemap/contact links could follow the nav but absolutely place them at the top. Next comes the content element which again will need no special positioning as it will fall right into place and be aligned with margins.

There would be very little need for any absolute positioning and no movement via relative positioning.

Your welcome div should really be done in three slices with a top, a repeating middle section and then a bottom section to cap it off. That will allow the middle section to expand should anyone resize the text in the browser. Fixed heights should be avoided as I mentioned before when you are presenting fluid content. You can get away with it in the header as there is little content but for passages of text you need to cater for text resize.

You also have a horizontal scrollbar because you have placed that bushed element absolutely but applie much to large a width. The width only needs to match the image and not the whole layout.

I also note that you are using the html5 doctype but you do not have the shim for IE8 nor have you set the html5 elements to display:block. You will need both of those to make it work in IE8 ands under.

I hope that explains the issues and don't worry its a common mistake to use relative positioning but it just isn't meant for that. It's used for more subtle effects when you want to move something to make it perhaps overlap but while not affecting the flow of the document.

I would have knocked you up a demo but I;m in the middle of a job that has to be finished but if you are still stuck then shout and someone will help

dresden_phoenix
—
2013-03-17T18:44:36Z —
#7

WOW. I have to say,you NEED to rethink your CSS techniques from scratch. The white space is there because of your use of position:relative; to position elements. BAD!!! See, position relative, moves where the element is DISPLAYED but not where it actually exists on the regular flow. In other words, it leaves a gap where it used to be. so the elements you have moved left or up, still are taking up space on the right or bottom( and thus your 'mystery white space'.

BTW it also a bad idea to set absolute dimensions on container elements.. what if you ever had to accommodate more, or bigger text??

Also I would reconsider the use of empty elements to hold decorational images, using wrappers would be far more semantic, and remove the dependence on RP.

JohnoLFC
—
2013-03-17T21:09:50Z —
#8

Paul/Dresden,

Thank you for your time and efforts with your explanations. They have been very helpful!

I have now made the recommended changes (except for the brown table area)

Is this an improvement? It certainly fixed the additional whitespace! Thanks again chaps

dresden_phoenix
—
2013-03-18T00:11:11Z —
#9

Your graphic could have been sliced a little different , but here is an example of what I was talking about , Essentially the branding part of your site . note I dont have <tag></tag> in my html. also note that elements with RP do not have top/left/right/bottom appied to them. I used RP mostly as a reference for AP elements. BTW, the only extra image I used is grass4.png, which is grass3.png flipped upside down in photoshop.

Another suggestion, which I didnt have time to implement , make your main nav into ONE LARGE SPRITE ( as opposed to one sprite per button) , not only will it be easier to manage, but your page will load faster.

My code /colors are a little sloppy as I did this by eye and in between projects, still you can see how much cleaner and easy to read this is, hopefully you can see what i did here and apply it to the rest of your site.

I have now started to read up from scratch on CSS positioning and basic HTML layouts. Hopefully will stop me making such a horrendous attempt in the future! Thanks for your feedback and its been definitely noted

PaulOB
—
2013-03-18T15:55:33Z —
#11

Don't worry we all made the same mistakes and is all part of the learning process:)