Block-level, inline, and inline block-level element basics of html

Source: Internet
Author: User

Block-level, inline, and inline block-level element basics of html

Concept

Block level: block

Inline: inline

Inline block level: inline-block

 

In html elements, the element has the display attribute.

The default value of the display attribute is block, so this element is a block-level element.

The default value of the display attribute is inline, so this element is an inline element.

The default value of display without elements is inline-block.

The value of the display attribute can be set. For example, you can set the value of the display of the block-level element div to inline, so it becomes an inline element and will not be displayed independently.

 

Features

1. Block-level elements

Exclusive row.

You can set width, height, margin, and padding.

It can contain block-level or Inline elements.

2. inline Elements

And other inline elements.

Setting widht, height, margin-top, margin-bottom, padding-top, and padding-bottom is invalid. You can set margin-left, margin-righ, padding-left, and padding-right.

It can contain block-level or Inline elements. When a block-level element is contained inside, the block-level element is displayed independently, and the next inline element is displayed with a line break.

3. inline-block

And other inline elements.

You can set width, height, margin, and padding like block-level elements.

It can contain block-level or Inline elements. When a block-level element is contained inside, this block-level element is displayed independently within the inline element, without affecting the row-level display of the next inline element.

Common block-level elements

Div, form, p, table, h1 ~ H6, hr, dl, ol, ul, pre, etc.

 

Common inline Elements

A, img, input, span, br, select, strong, em, textarea, label, etc.

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.