Why define the ul {margin: 0; padding: 0;} selector in the css file?

Source: Internet
Author: User

Why define the ul {margin: 0; padding: 0;} selector in the css file?

Why define the ul {margin: 0; padding: 0;} selector in the css file?

Ul labels have padding values by default in FF, while only margin has default values in IE. What are the default values of padding and margin in the following views?

IE effect:

 

IE result: margin-left: The default value is 40px;

 

FF effect:

 

 

Firefox result: padding-left: 40px;

 

Wekkit effect:

Webkit padding-left: 40px;

 

Webkit results are the same as Firefox: padding-left: 40px;

Based on the default values of ul's margin and padding, ul {margin: 0; padding: 0;} is set to unify the attributes of ul's margin and padding in most browsers. .

HTML:

    CSS:

    Body, ul {padding: 0; margin: 0 ;}# box {width: 600px; height: 100px; background: blue; cursor: hand ;}li {width: 600px; height: 20px; background-color: red ;}

    Related Article

    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.