Re: DOCYTYPE & CSS

by Andrew McFarland <aamcf(at)aamcf.co.uk>

 Date:  Wed, 13 Feb 2002 20:37:20 +0000
 To:  <hwg-basics(at)hwg.org>
 References:  means
  todo: View Thread, Original
At 07:13 14/02/02 +1300, Richard Lake wrote:
<.snip/>
>The problem is that the margins for P and H1 from the stylesheet (as
>follows) is now being ignored, everything else is working as before (This is
>with IE6 and N6).
>
>h1    {
<.snip/>
>         margin-top: 10; margin-bottom: 10;}
>p       {
>         margin-right: 40; margin-left: 40;
>         margin-top: 15; margin-bottom: 15; }
<.snip/>

The problem is the CSS is invalid. You always need a unit after lengths. 
For example, your h1 rule should be

h1{
         margin-top: 10px;
         margin-bottom: 10px;
}

Some DOCTYPEs change the way some browsers operate. With no DOCTYPE, they 
render pages in quirks mode, where they (among other things) tend to be 
more forgiving of mistakes. With certain DOCTYPEs they switch to strict 
mode, where mistakes are not corrected. For more information, see 
http://www.mozilla.org/docs/web-developer/quirks/

The W3 CSS validator would also have picked up this problem. Its worth 
getting to know; see http://jigsaw.w3.org/css-validator/

Andrew

--
http://aamcf.co.uk/

HTML: hwg-basics mailing list archives, maintained by Webmasters @ IWA