Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums CSS margin error in firefox and ie browser despite reset Re: margin error in firefox and ie browser despite reset

#108171
wolfcry911
Participant

do you have a link to test page or image showing the problem? How much margin?

as you’re just learning, I’ll give a few pointers. Don’t worry about general resets right now – you’ll have time to learn and review them in the future when you better understand things. Looking at the reset you used, none of the 4 elements you selected have a border by default, so that’s unnecessary. divs have zero margin and padding as default in all browsers, so that too is unnecessary. html and/or body will have margin and/or padding applied so that makes sense. And unless you want p elements slammed against other elements, either leave the default margin/padding or set the value you’d like to have – why set it to zero only to overrule it later? I understand that in this test case you may want 0 margin – that’s fine. That’s enough on the reset…

The #container is a div, has no margin, padding, or border by default (which you’ve set to zero anyway) and because it’s a block level element, takes up all available width anyway. Setting width: 100% will introduce problems if you want padding later. The only rule needed is the background-color.

Why a transitional doctype? There is no reason a new page should be developed under one – use a strict doctype. I’d also abandon xhtml and use html5. While not yet a CR, it’s the future, backwards compatible, and can safely be used right now (not to mention so much easier to use).

As to the problem – have you used the style tags in the css file? If so, remove them. They are used for adding styles in the head section of an html document. Otherwise, I see no reason for things not to work.