Understanding and mutual conversion of elements in HTML rows and block-level elements

Source: Internet
Author: User

Understanding and mutual conversion of elements in HTML rows and block-level elements

Block-level elements:Div, p (paragraph), form (form), ul (unordered list), li (list item), ol (ordered list), dl (definition list ), hr (horizontal split line), menu (menu list), table (table )...

  Features:1. A block-level element occupies only one row, and its width automatically fills the width of its parent element.

2. You can set the width and height attributes. (Even if the width is set, only one row is exclusive unless the float attribute is used in special cases)

3. You can set the margin (outer margin) and padding (inner margin ).

Line element:Span, strong, em, br, img, input, label, select, testarea...

(Line elements, inline elements, embedded elements, and straight-forward elements refer to "inline elements ")

  Features:1. An element in a row does not exclusive to a row. The elements in the adjacent row are arranged in the same row. The line breaks only when the row does not exist, its width varies with the content of the element (its width is extended by the content ).

2. Setting the width and height attributes is invalid.

3. the padding effects are generated for padding-left, padding-right, margin-left, and margin-right in the horizontal direction,

However, padding-top, padding-bottom, margin-top, and margin-bottom in the vertical direction will not produce any results.

 

Variable element:Determine whether the element is a block-level element or a Row Element Based on the context. It belongs to the preceding two element categories. Once the context relation determines its category, it complies with the rules and restrictions of block-level elements or intra-row elements.

 

CSS:Css can change the default layout of html and place block-level elements in the desired position.

The basic difference between block-level elements and intra-row elements is that block elements generally start from a new row. After css control is added, this attribute difference will not be different.

ToLine ElementAddDisplay: blockSuch an attribute allows the Row Element to have attributes starting from the new row each time.

ToBlock-level elementsAddDisplay: inlineThis attribute prevents block-level elements from attributes starting with a new row.

 

ToLine ElementAddDisplay: inline-blockAttribute, but you can set the width and height attributes.

(This article is for learning and communication only. If you have different opinions, you are welcome to leave your valuable comments ~)

 

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.