CSS block-level elements and inline Elements

Source: Internet
Author: User

Elements in a page are generally divided into two types: block-level elements and intra-row elements (Inline elements). These elements are actually divided into two types, so there must be a difference between them:
1. Block-level elements always occupy only one row. There is a line break between the front and back, and the inline element always occupies one row with other inline brothers.
2. Block-level elements can be configured with width and height values, so inline elements will not work. Their width and height will always automatically expand and decrease as their content grows.
3. the margin and padding of block-level elements are normal, the left and right maring and left padding of inline elements are normal, and the upper and lower layers are not recognized. That is to say, the Row Height cannot be changed through margin-top and padding-top. (The padding between the line element margin and padding is completely parsed in each browser, and the padding between the upper and lower layers is the cup. The resolution of Each browser is different. Setting a background seems to be recognized by others, however, the elements around him do not set the upper and lower spacing when they do not exist. Therefore, in future projects, they will not set the upper and lower margin and padding for the elements in the row)

Summary: If you want to exclusively occupy a row, block-level elements (DIV, DL, DT, DD, UL, li...) will be displayed ...), if you want to make the elements and other elements in a row use the line elements (span, A, IMG), you can use styles to convert disply: block; display: inline;

Related Article

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.