SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Enthusiast polyhedra's Avatar
    Join Date
    Nov 2011
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question on <body> tag's style

    Hi hope everyone is alright,
    I am working through the Site point book (very helpful) So why add
    HTML Code:
    PADDING: 0;
    styles for
    HTML Code:
    <body>
    when the default style for body is just
    HTML Code:
    MARGIN: 8px;
    Because the padding already set by default at zero? Something to do with different browsers applications out there?

    More Info

  2. #2
    It's all Geek to me silver trophybronze trophy
    ralph.m's Avatar
    Join Date
    Mar 2009
    Location
    Melbourne, AU
    Posts
    23,598
    Mentioned
    411 Post(s)
    Tagged
    6 Thread(s)
    Each browser has its own defaults, so to account for them all, there are resets like the above. Perhaps not every element needs zero padding and margin, but it's easy enough just to include them all in the one rule. I've never used a browser that had any default margin or padding on a div, for example, but I hear there is (or was) such an one.

  3. #3
    The CSS Clinic is open silver trophybronze trophy
    Paul O'B's Avatar
    Join Date
    Jan 2003
    Location
    Hampshire UK
    Posts
    39,803
    Mentioned
    158 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by polyhedra View Post
    Hi hope everyone is alright,
    I am working through the Site point book (very helpful) So why add
    HTML Code:
    PADDING: 0;
    styles for
    HTML Code:
    <body>
    when the default style for body is just
    HTML Code:
    MARGIN: 8px;
    Because the padding already set by default at zero? Something to do with different browsers applications out there?

    More Info
    There is no set default style sheet for browsers makers to adhere to and they can use whatever they wish and although they are encouraged to standardise it is not a requirement.

    Newer versions of browsers are tending to be closer in their defaults but there is no guarantee. Previously some browsers used margins on html and some like opera used padding and some like IE applied styles to the body element instead.

    Therefore the standard practice for old and new browsers is simply to zero margins and padding on html and body e.g. html,body{margin:0;padding:0}.

    There are many other anomalies such as the default space for bullets on lists which some browsers use padding and some use margin so you need to address both.

    It would be nice if all browsers used the same measurements but then why would you want a browser telling you how much margin to apply. It's your job as a designer to set the requirements for your layout that you need.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •