The difference between margin and padding

Source: Internet
Author: User

At present web2.0 has been recognized, because like to engage in web development people have to bite the bullet to learn web2.0 standards, one of the important is the new layout rules, div+css. Used to be basically table layout, this traditional way is simple and intuitive, but this new standard I learn often can not find the north. Oh, take today's example, a lot of friends must also have my situation, then I will collect some examples from the Internet, let a lot of people to eliminate this annoyance.

Case one:

The difference between padding and margin in CSS


margin outer margin

Border border

padding inner margin

That is, set the margin, and the empty space he occupies will be outside the border.

Setting padding the space in which he occupies is inside the frame, which is clearer to illustrate.



For example, a, B two boxes, a code padding,b for margin, now we look at the distance between a arrow and the blue border, this is padding called the inner margin, and then take a look at the outside B arrow and B before the distance is what we call margin, called the outer spacing, Haha you should understand now, what is padding, what is margin? Oh

Case TWO:

Look at the CSS box model! Margin is the distance between the div and the surrounding elements padding is the distance from the div inside the div




The difference between margin and padding

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.