The difference between margin and padding in HTML

Source: Internet
Author: User

We take div as a box example, since and show the life of the box, then we think about the life of the box

The interior is not empty good for storing things, and inside the area of storage we give him a name called "Content (internal

", and the paper wall of the box gives him a name called" Border (border) ", if something inside the box is like a hard

Disk, but the hard drive is afraid of vibration, so we need to evenly fill some of the shock-proof material inside the hard drive's surrounding box,

The frame of the hard disk and the box has a certain distance, we call this part distance is called "padding (padding)", if

We need to buy a lot of hard drives, or because the hard drive is afraid of vibration, need some shock between the box and the box

Material to fill, then the distance between the box and the box we call "margin (margin)"

Good drop! The four elements of the box model are: content, border (border),

Padding (inner margin), margin (margin), such as

Our pages are made up of dozens of boxes, but unlike real-life boxes, real-life

We'll ignore margin, but in the page we can't ignore margin, only the

The box model that includes the margin is complete in CSS, and when the margin is zero, let's not ignore it, and know that he

Is there.

The content comes from the watercress's sails

The difference between margin and padding in HTML

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.