I avoid using the defaults with the reset code below:
margin:0px; and padding:0px;
For example, what are the default margins for the heading tag below?
<h1>Header</h1>
By default, the margin value of some HTML elements is set to zero, though some elements have specified margin values as their default, such as the <h1> through <h6> heading tags. Margins of two different elements are also allowed to overlap sometimes in a behavior called margin collapse.
However, an H1 for example has a top and bottom margin: . 67em; , by default. These top & bottom margins grow all the way to 2.33em for an H6 .
HTML defines six levels of headings. A heading element implies all the font changes, paragraph breaks before and after, and any white space necessary to render the heading. The heading elements are H1, H2, H3, H4, H5, and H6 with H1 being the highest (or most important) level and H6 the least.
To break it down, remember: H1 = Main keywords and subject matter, what the overall post is about. H2 = Sections to break up content, using similar keywords to the H1 tag. H3 = Subcategories to further break up the content, making it easily scannable.
It varies between browsers. Check each browser's specific default stylesheets to tell.
For Google Chrome for example, it's 0.67em
.
Do know that if you wish to aim for x-browser consistency, you'll have to use a CSS Reset.
The most common one being:
* { padding: 0; margin: 0; }
Although other (and probably better) exist.
It's different regarding which browser, thus if you want a pixel-perfect design then practice is to "reset" those values to 0 (margin and padding) and set them yourself.
"CSS reset" is very common to front-end developers, a simple example of one i use :
html,body,blockquote,code,h1,h2,h3,h4,h5,h6,p,pre{margin:0;padding:0}
button,fieldset,form,input,legend,textarea,select{margin:0;padding:0}
fieldset{border:0}
a,a *{cursor:pointer}
div{margin:0;padding:0;background-color:transparent;text-align:left}
hr,img{border:0}
applet,iframe,object{border:0;margin:0;padding:0}
button,input[type=button],input[type=image],input[type=reset],input[type=submit],label{cursor:pointer;}
ul,li{list-style:none;margin:0;padding:0;}
strong{font-weight:bold;}
em{font-style:italic;}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With