12

I noticed that the <p> tag has a default margin value and it seems it's somehow related to its content's font-size value.

Is there any reference that I can check out the detailed rules for this?

http://jsfiddle.net/z45R9/ Please take a look at my code here.

Thanks,

AGamePlayer
  • 7,404
  • 19
  • 62
  • 119
  • 3
    This question is answered here: http://stackoverflow.com/questions/819161/what-is-the-default-padding-and-or-margin-for-a-p-element-reset-css – Bill Forney Dec 31 '13 at 02:04

3 Answers3

11

Different Browsers are built upon different render engines.

Chrome and Safari use the WebKit-render engine, whereas Firefox uses Gecko.

The different engines are different not just because the software is different but also because they have different settings. That's why most web pages look slightly different in different browsers.


The Answer:

In Chrome (webkit), the margin-top (above the element) and margin-bottom (below the element) of the <p> tag is 1em.

In Firefox (Gecko), all margins are 0 except the margin-bottom, which is 1em again.

The way to get rid of this problem is to make a CSS-reset. The easiest to use would be the one by Meyerweb.

László Monda
  • 1,647
  • 1
  • 16
  • 29
Friedrich
  • 2,211
  • 20
  • 42
2

The default value of

margin depends on the browser. For example, the CSS 2.1 especification define this default stylesheet for HTML 4. But some browsers can use this, and others not. Its not a rule, just a reference.

Pedro Vítor
  • 191
  • 1
  • 6
0

There are many different browsers, and they all can have their own unique way to do things. For that reason, most designers put a css reset in their css stylesheet.

http://meyerweb.com/eric/tools/css/reset/

By putting that reset in your file, it will enable you to better control how your website looks on all browsers. Instead of worrying about what each browsers default is for each thing.

CRABOLO
  • 8,605
  • 39
  • 41
  • 68