Deep understanding of the difference between block-level elements and inline elements in CSS (individual error points)

Source: Internet
Author: User

Difference One:

Block-level: block-level elements will have a single row, and width automatically fills the width of its parent element by default

Inline: Inline elements do not monopolize a row, and adjacent inline elements are lined up in the same row. Its width changes depending on the content.

Difference Two:

Block-level: block-level elements can be set to a wide height

Inline: In-line elements cannot be set to width height

Difference Three:

Block level: Display:block;

In line :display:inline;

You can toggle block-level elements and inline elements by modifying the display property.

Difference Four:

Block level: block-level elements can be set margin,padding

In-line: the horizontal direction of the elements in the margin-left; Margin-right; Padding-left; Padding-right; can take effect. But the vertical direction of the margin-bottom; Margin-top; Padding-top; Padding-bottom, but not effective.

Deep understanding of the difference between block-level elements and inline elements in CSS (individual error points)

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.