A strange discovery: HTML and body,body margin do not work with HTML, HTML padding works for the body __html

Source: Internet
Author: User

eg

<style>

Html

{

BORDER:2PX solid blue;

}

Body

{

BORDER:2PX solid red;

margin:100px;

padding:50px;

}

</style>

<body>

This is the text section.

</body>


1. In the first case:

Body has margin,html not padding:

You can see that no matter how big the body of the margin, the body and the HTML side of the paste.


2.html has padding;

When the HTML has padding, it will affect the body size, so that the body shrinks.


The margin of the included module in HTML cannot change the size of the containing module, but it can affect the location of the included module in the containing module (HTML and body is an exception) and can change its size only if the containing module itself has padding.

eg

. One
{

BORDER:2PX solid blue;

}


. Two

{

BORDER:2PX solid red;

margin:50px;

}



<div class= "One" >

<div class= "Two" >

This is the text section.

</div>

</div>








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.