A brief analysis of Css-reset and personal understanding

Source: Internet
Author: User

A superficial understanding of css-reset

Recently in retrospect some of the past knowledge, think of css-reset time, think it is time to comb some of the personal views and hidden points of knowledge, may not be comprehensive, but some summary is necessary.

We all know that in the process of front-end development, we often have to get rid of the browser's default style, this time we have a concept in mind, that is css-reset this must appear. However, I find that in the case of the default style cleanup, we sometimes don't think about what the default style is in the browser. In order to prove some of my ideas, I deliberately reviewed some of the default styles of the tags, now summarized as follows

  

Body {           margin:8px;} P,DL {   margin:;  }

h1{

MARGIN:21.4333PX 0; /* Final Test accurate to ... */
}

h2{

MARGIN:19.9167PX 0;
}

h3{

MARGIN:18.7167PX 0;
}

h4{

MARGIN:21.2833PX 0;
}

h5{

MARGIN:22.1833PX 0;
}

h6{

MARGIN:24.9667PX 0;
}

ol,ul{

MARGIN:16PX 0;
padding:0 40px;
}

DL dd{

margin-left:40px;
}

There are also some default underline styles such as a label, the title label H1-h6 each has a default style margin, not many say:

  

      

      

So we simply summed up some of the common HTML tags in the browser's default style, so that we can later in the work to be affected by these default styles, we have to remove these styles, so css-reset out:

 body,p,h1,h2,h3,h4,h5,h6,dl,dd  { margin : 0 ;     font-size : 12px ; /*  FONT-FAMILY:XX;  */} ol,ul  { List-style : none ;  padding : 0 ;  margin :  0 ;} a    { text-decoration : none ; }img  { border :  none ;} 

When I use IE tester test to find my tool error, so can not correctly explain IE6 and Firefox under the style differences under the browser, you can test yourself under IE6.

The following situations need to be explained:

1) The font size under both browsers, i.e., Font-size is different, so we reset its default properties in the CSS Code section above. We also have different fonts on each browser, although our default is Arial, but sometimes we will use a font style such as Microsoft;

2) IE6 A default bounding box appears when the default IMG tag Image 2.png as a link content, so we clear its border.

At the end of this article, we enclose the test documents for your reference.

1 <!DOCTYPE HTML>2 <HTMLLang= "en">3     <Head>4         <MetaCharSet= "Utf-8">5         <title>Some analysis of the css-reset behind</title>6         <style>7 Body{8 Height:1000px;9 Border:1px solid Red; /*easy to view browser default styles*/Ten             } One         </style> A     </Head> -     <Body> -         <ahref="#">A-tag (link, download, Anchor point)</a> the         <imgsrc= "2.JPG"alt= "Beauty"> -         <ahref="#"><imgsrc= "2.JPG"alt= "Beautiful link"></a> -         <BR> -         <span>Style-sensitive text markers</span> +         <BR> -         <Strong>Emphasis on Bold</Strong> +         <BR> A         <em>Italic</em> at         <P>Paragraph</P> -         <Div>Block</Div> -         <H1>Title 1</H1> -         <H2>Title 2</H2> -         <H3>Title 3</H3> -         <h4>Title 4</h4> in         <h5>Title 5</h5> -         <h6>Title 6</h6> to         <ol> +             <Li>There are sequence table entries 1</Li> -             <Li>There are sequence table entries 2</Li> the             <Li>There are sequence table entries 3</Li> *         </ol> $         <ul>Panax Notoginseng             <Li>Unordered list Item 1</Li> -             <Li>Unordered list Item 2</Li> the             <Li>Unordered list Item 3</Li> +         </ul> A         <DL> the             <DT>Defining list Headings</DT> +             <DD>Defining list Items 1</DD> -             <DD>Defining list Items 2</DD> $             <DD>Defining list Items 3</DD> $         </DL> -     </Body> - </HTML>

  

Description: The above test is in Firefox, the default style of the title Tag section of the margin value may not be the same, it just means that it has these default styles.

      

  

A brief analysis of Css-reset and personal understanding

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.