PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, July 18, 2022

[FIXED] why do browsers style a predefined margin into all webpages?

 July 18, 2022     css, document-body, html     No comments   

Issue

Why do all browsers style an arbitrarily sized margin on the <body> element of all webpages?* I'm not surprised by this, as I've been making webpages for years now, but I just assumed it was part of the spec, in the same way text inside <strong> should be bold. But, as seen in HTML5, HTML 4.01, HTML 4.0, HTML 3.2, and even HTML 2.0 and the RFC Definition, default styles are never even mentioned!

I can't find any definitions of HTML before 2.0, which was released upon the world in 1995, so why would all browsers insert the very specific 8px margin on all webpages*, especially in these days where every website removes it in the first few lines of CSS (even the HTML 4.01 spec's stylesheet does this) or a normalize/reset stylesheet? Sure, one could argue that ancient websites like the above listed HTML 3.2 spec rely on this, but they really don't look bad without the margin (try removing it with your browser inspector).

*** by "all browsers", I mean all versions of Chrome, Firefox, IE, Opera, and Safari, including all related obsolete versions, betas, alphas, and nightlies, as of this question.


Solution

Browsers have to have a default rendering of some kind (author stylesheets didn't exist when HTML was first introduced and are still an optional extra today).

If there was no margin/padding on the body/html then the text would run up against the window border and toolbar where it would be very hard to read (which would be a poor choice for a default rendering).

why would all browsers insert the very specific 8px margin on all webpages

"But it looks different in Netscape" was a common complaint. Browsers copied the default rendering from each other to compensate for authors writing pages and only thinking about one browser.

where every website removes it in the first few lines of CSS

Not every website does. It's a common (but not universal) practise for sites which are going to include a stylesheet, but not all sites do.



Answered By - Quentin
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing