Forum Moderators: open

Message Too Old, No Replies

Must I close a global <DIV> tag

         

kaled

10:50 am on Jul 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In order to get things rendered identically on all the major browsers, I've had to resort to using a <DIV ID="body"> for the whole body of my pages.

My question is this. Must I include </DIV> at the end of the page or is it closed by the </BODY> tag? IE, Opera and FF all render correctly if I omit the </DIV> tag.

Obviously, to be safe I must include the final </DIV> but for reasons I don't want to get into, I'd like to omit it. Can anyone give me a definitive answer?

Thanks

Kaled.

sidyadav

11:38 am on Jul 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hm.. never tried that, this really brings you to the old "Validation VS Rendering" question - a real hard decision but it's up to you.

If I were you, I'd try my hardest to find an alternative (hopefully someone here helps out) and if it doesn't work out, I'd choose rendering.

Sid

encyclo

12:03 pm on Jul 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If you want it to validate, then you should close the tag. It is unlikely to cause any rendering problems if you don't, though.

The real question is whether the div is neccessary - can't you just add the

id
attribute to the
body
tag instead?

Dudermont

2:38 pm on Jul 5, 2004 (gmt 0)

10+ Year Member



I am almost certain that it is not going to be closed by the </body> tag. The name you set the id attribute to makes no difference on that. It may still render properly but as I am sure you know, some pretty bad code can still render properly.

But if you are already not writing valid code, why worry about that one div? The error correction that the browsers have seem to know what to do with it.

kaled

5:51 pm on Jul 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks,

The reason for using a DIV for the whole body is that I'm placing a banner across the top of the screen using position:absolute. Firefox is ok with this but Opera and IE both calculate the width incorrectly if body margins are non-zero.

To make it more complex, I'm using both frames and iframes depending on whether javascript is enabled - Yikes!

Kaled.

tedster

7:15 pm on Jul 5, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Opera and IE both calculate the width incorrectly if body margins are non-zero

Just a thought -

You might experiment with a rule that gives the <html> element (senior to the <body> element!) some padding rules. Those rules, it the problematic browsers apply them, could replace any <body> margin rules you found necessary, and maybe get around the absolute positioning problem you tripped over.

I agree that with current browsers an unclosed "global" <div> is unlikely to run into rendering problems because of error recovery - however I would check Mac IE5 and Safari before going forward.

However, you never know about the future browser versions (such as the upcoming IE update.) Valid mark-up is one of the best ways to future-proof your website, so I would definitely give some thought as to how that can be accomplished with your layout's needs.