Forum Moderators: open

Message Too Old, No Replies

Doctype and Padding

MSIE 5/6 NS6 Inconsistencies

         

Googly

9:59 am on Feb 7, 2003 (gmt 0)



I started off with this <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> as my doctype. I had added padding of 5px to a layer. In MSIE 5 and 6 the padding was 'correct' and was added around the text in the layer giving a 5px padding. However NS 6 expanded the layer slightly instead.

I have since found out that NS 6 is infact the one that is correct and that MSIE is wrong. By adding <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> and resizing the layers I found that NS6 and MSIE 6 became identical in the layer's pixel coverage.

However, in MSIE5 the layer then shrunk.

Could anyone suggest a solution which would allow padding and also match these 3 browsers. I doubt it, but there might be a possibility so I'll still ask. Hope you can help.

Googly

DrDoc

6:46 pm on Feb 7, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



There's always the possibility of wrapping one div around the other. Apply size to the outer div, and padding to the inner ..

benihana

1:48 pm on Feb 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



hi
there is a good tutorial on a work around that i think may help with the padding in IE 5.
ill stickymail the link.
hope it helps
ben

DrDoc

5:38 pm on Feb 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



benihana, are you talking about a work around that uses Tantek Çelig's box-model hack? If so, at least as a personal preference, I try to avoid any hacks if there are other workarounds.

Remember a couple of years ago? It was almost mandatory to use a handful of different hacks to make the page look the same, or at least ok, in most browsers. Today we've learned to avoid HTML hacks. Most Web developers uce valid HTML when coding, combined with CSS.

Sure, now we've realized that not all browsers understand CSS the same way. Naturally there are several ways to find our way around those bugs. We can, for example, avoid the certain rule that causes problem. Or, we can create a less strict layout, one that doesn't require pixel perfection, and is therefore more fluid. Or, as a last resort we can try to find a hack or similar workaround.

Again, personally I prefer the second option - to create a more forgiving layout. It is, using hacks or not, almost impossible to make it look the same. And, even if that look is acheived .. then we've only been able to target the five or so most common browsers. What about the others?

Finally, if a hack has to be used (and I'm using the word "hack" as a very general and broad term, meaning any kind of standard-wise unnecessary workaround) .. the hack should always validate. If a hack or workaround validates, then you can be almost sure it won't cause any problems in the future, and that it won't affect unknown browsers too dramatically. Still, it's better if it can be avoided entirely.

We really don't want to start using a handful of hacks for each browser again, do we? ;)

benihana

8:15 pm on Feb 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



> are you talking about a work around that uses Tantek Çelig's box-model hack?

Yes.

>Remember a couple of years ago?

Generally, yes. :) In terms of css and html, no.

> Again, personally I prefer the second option - to create a more forgiving layout.

I agree, ive never made a layout that couldnt cope with a slight nudge here and there, and i have never employed this particular technique to workround IE5 issues. However I remembered seeing it described once and thought i would throw it into the mix as an option. thats all.

ben

DrDoc

8:53 pm on Feb 8, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Okies .. was just wondering :)

RZaakir

7:26 pm on Feb 10, 2003 (gmt 0)

10+ Year Member



Hey Googly,

You're right in that the IE5 CSS box model is in fact broken. IE6 emulates it if you don't set your DTD properly. There is a very ugly (in terms of how it makes your stylesheet work) workaround for this problem here:

[glish.com...]

I don't know if this validates or not (I doubt it) because I'm too hardheaded to hack my code to accomodate for bad parsing code.

::Add::
This is the Tantek box-model hack. Feel free to flog me. Or destroy the link.

Googly

1:29 pm on Feb 11, 2003 (gmt 0)


Thanks for all your advice guys. Although fully digesting your ideas I think that I have come across what seems to be the ideal solution. A very clever css expert was kind enough to enlighten me.

He said to me:
"A lot of folks use hacks for the box model, but I prefer using proprietary Microsoft conditional statements (hair of the dog :?-). Put this below all other style sheets in your <head>

<!--[if IE 5]>
<link href="ie5boxhack.css" rel="stylesheet" type="text/css">
<![endif]-->

Then, in ie5boxhack.css, enter the curative dimensions :-)"

Well, after a bit of playing around, my test page is now pixel perfect to a high degree in MSIE 5.x and 6 and NS6 and hopefully 7, which is great!
Any thoughts?

DrDoc

9:46 pm on Feb 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I think that's a wise approach, Googly :)

RZaakir

5:05 pm on Feb 12, 2003 (gmt 0)

10+ Year Member



I would agree with the last post, good work! I might have to "steal" that code for my future projects... heh heh...

ricfink

3:24 am on Feb 14, 2003 (gmt 0)

10+ Year Member



Using IE's conditional comments to load different styles is definitely the way to go when bridging the divide between IE5 and IE6 running in "strict" mode.

You're not only on the right track, but in my opinion, the only track that makes any sense.