(10) Learn the Padding property of CSS

Source: Internet
Author: User

Browser support

All browsers support the Padding property.

Note: The property value "Inherit" is not supported by any version of Internet Explorer (including IE8).

Definition and usage

The padding shorthand property sets all padding properties in a declaration.

Description

This shorthand property sets the width of all inner margins of the element, or sets the width of the padding on each edge. The padding that is set on the inline non-replacement element does not affect the row height calculation, so if an element has both an inner margin and a background, it may visually extend to other rows and may overlap with other content. The background of the element extends through the inner margin. You are not allowed to specify a negative margin value.

Note: Negative values are not allowed.

Example 1
padding:10px 5px 15px 20px;

    • Top padding is 10px
    • Right inner margin is 5px
    • The lower padding is 15px
    • Left margin is 20px
Example 2
padding:10px 5px 15px;

    • Top padding is 10px
    • Right padding and left padding are 5px
    • The lower padding is 15px
Example 3
padding:10px 5px;

    • Top padding and bottom padding are 10px
    • Right padding and left padding are 5px
Example 4
padding:10px;

    • All 4 internal margins are 10px
value describes the inner margin that the        auto     Browser calculates. Length   Specifies the value of the padding in a specific unit, such as pixels, centimeters, and so on. The default value is 0px. % Specifies the padding         based on the percentage of the parent element's width. Inherit  specifies that the inner margin should be inherited from the parent element. 

Default value: 0.

(10) Learn the Padding property of CSS

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.