Default padding and margin for body

liunx

Guest
Hello. I created a small document, one with a absolute positioned image. all browsers, mac and windows, placed the img in the exact same place except for opera, but when i set the padding;0px on the body, opera placed it in the same spot. so my question is... opera must have a defualt padding value set on the body, does anybody know what this is? Is opera compliant here, or the other browsers? I tried to read the <!-- m --><a class="postlink" href="http://www.w3.org/TR/REC-CSS2/">http://www.w3.org/TR/REC-CSS2/</a><!-- m --> , but i couldn't find any mention of this. Thanks.Hello. I created a small document, one with a absolute positioned image. all browsers, mac and windows, placed the img in the exact same place except for opera, but when i set the padding;0px on the body, opera placed it in the same spot. so my question is... opera must have a defualt padding value set on the body, does anybody know what this is? Is opera compliant here, or the other browsers? I tried to read the <!-- m --><a class="postlink" href="http://www.w3.org/TR/REC-CSS2/">http://www.w3.org/TR/REC-CSS2/</a><!-- m --> , but i couldn't find any mention of this. Thanks.

Unless it's a typo in your code, it is not "padding;0px" but "padding:0;" or "padding:0px" if you must (because it is zero, you can omit the "px" as zero pixels = zero points = zero em = zero ex, etc. but omitting this is purely optional).

In any web page, you should start out your *css with this:

<style>
body, html
{margin:0; padding:0; border:0;}
</style>

This re-sets these three important selectors to "zero" by declaration. IE is noted for 'assuming' a pixel or three off from being correct.
I am doing this (above) to ALL my web page creations anymore... It corrects a bug in IE, and best of all, does not affect the other, 'compliant' browsers as they are (supposedly) this way by default (which is correct).
WHY you are seeing something in OPERA is up for grabs, but the above code, if nothing else, will start you out with a clean-slate so to speak.

And, -does your page have a !DOCTYPE statement at the beginning? If not, perhaps some browsers are 'just winging it' to chance and perhaps OPERA really expects and requires a valid !doctype. I remember that there was some small issue years ago with NS (v.4?) having problems with certain ab-positioned elements due to it's having the right-hand side vertical scrollbar... But I doubt that this bears any relevance to the current complaint. :)ehhh... whats a doctype....? oh wait, im a professional web site programmer... ok, so all that said, my question hasn't really been answered. my doctype is fine, and there is no type, typa, typi, arrgghh!! typO! I set the body element with all zeros with 99% of the code i write, im asking: What is the CSS 2 default body padding and margin. You said zero, and thats what i thought(except the IE thing, i knew that), im wondering why opera did this. thanks.I guess your question exceeded the sum of the words used, and it wasted my time to try to assist. Sorry.sorry man, i do appreciate the help, i guess i was subconciously irritated by the "are u a noob" tone of the the feedback. not your fault, i realize the scope of users in this forum. i was wondering if anyone had insight to "Opera" on this issue.Just to clear things up.

If there is a DOCTYPE present, IE and Firefox will be in standards compliance mode, if not then they will be in quirks mode. However, if you're using XHTML and include the XML prolog, then IE will revert to quirks mode, because all it looks for at the beginning of an (X)HTML document is "<!DOCTYPE" and if it sees it, it goes into standards compliance mode. When you include the (optional) XML prolog, the DOCTYPE is not at the very beginning of the document and so IE shows how good it really is once again.

Opera on the other hand is ALWAYS in standards compliance mode, because it has no quirks mode.

Without seeing any page code it's not exactly easy to say what the problem could be, but with what you've given so far, it does seem as though you simply declared the padding incorrectly, "padding;0px".
 
Back
Top