Home > Article > Web Front-end > What is the difference between block-level elements and inline elements?
The difference between block-level elements and inline elements: inline elements can be placed side by side with other inline elements, while block-level elements occupy an exclusive line and cannot be placed side by side with any other elements; inline elements cannot be set in width and height, while block-level elements can be set in width high.
The operating environment of this article: windows10 system, html 5, Acer S40-51 computer.
The differences between block-level elements and inline elements are:
(Learning video sharing: css video tutorial)
1. Inline elements Can be placed side by side with other inline elements; block-level elements occupy an exclusive line and cannot be placed side by side with any other elements;
2. Inline elements cannot be set in width and height. The default width is the width of the text; block-level elements can be set in width and height. , if the width and height are not set, the width will default to 100% of the parent.
Related introduction:
Block element is also known as block element (block element), and its counterpart is inline element (inline element), which are concepts in the HTML specification.
The basic difference between block elements and inline elements is that block elements generally start on a new line, and adjacent block-level elements will be displayed on different lines. When CSS control is added, this attribute difference between block elements and inline elements no longer becomes a difference.
For example, we can add an attribute such as display:block to the inline element, so that it also has the attribute of starting from a new line every time, that is, it becomes a block element. Similarly, we can add display: to the block element. Attributes like inline allow it to be arranged on one line.
Related recommendations: CSS tutorial
The above is the detailed content of What is the difference between block-level elements and inline elements?. For more information, please follow other related articles on the PHP Chinese website!