Differences between block-level elements and intra-row Elements

Source: Internet
Author: User

Differences between block-level elements and intra-row Elements

Block-level elements and intra-row elements are the two most basic layout elements. Common block-level elements include div, p, form, ul, ol, li, etc, common row elements include span, strong, and em.
What is the difference between block-level elements and intra-row elements?
A block-level element occupies only one row. By default, its width is automatically filled with the width of the parent element, and the elements in the row are not exclusive. The elements in the adjacent row are arranged in the same row, the line breaks only when a row is not arranged, and its width varies with the content of the element.
You can set the width and height attributes for block-level elements. The width and height attributes for intra-row elements are invalid. Even if the block-level elements set the width, they still occupy one row.
The margin and padding attributes can be set for block-level elements. The argin and padding attributes of the row elements are very strange. The horizontal direction is margin-left, margin-right, and padding-left, padding-right produces margin effects, but the vertical margin-top, margin-bottom, padding-top, and padding-bottom do not produce margin effects.
The CSS attribute of block-level elements and intra-row elements is display. block-level elements correspond to display: block, and intra-row elements correspond to display: inline. we can modify the dispaly attribute to switch block-level elements and intra-row elements.
--------------------------
Display: inline-block: it is a block-level element in a row. It has the features of block-level elements. You can set the length and width, set the margin and padding attributes, but it is not an exclusive row, its width does not fill the parent element, but is the same as the element in the row. It can be in the same row as the element in other rows.
IE6 and IE7 do not support display: inline-block, but can trigger hasLayout.
For example:

IE6 and IE7 do not support display: inline-block, but can trigger hasLayout.
Changing label p to span can trigger the hasLayout element in the row to simulate the display: inline-block effect. The span is aligned at the bottom of IE6/7 and in IE8/F.
Irefox is the top alignment, so * vertical-align:-10px; is required;

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.