Tag elements in HTML are generally divided into three different types: block elements, inline elements (also called inline elements) and inline block elements. So what is the difference between block elements and inline elements? Let me introduce it to you below.
##Inline elements
In html, , , Tags such as andare typical inline elements. Of course, block elements can also be displayed as inline elements by setting
display:inline;, so that block-level elements have the characteristics of inline elements.
p{ display:inline; } ...<p>我要变成内联元素!</p>
Characteristics of inline elements:
1. On thesame line as other elements, not on an exclusive line;
2. The height, width and top and bottom margins of elementscannot be set;
(ps: the top and bottom margins of inline elements, margin-top and margin-bottom attributes do not work , and the margin-left and margin-right attributes can work. The padding attributes top, bottom, left, and right can also work,but the padding-top attribute can only reach the top of the browser at most , padding- top is higher than the top of the browser, and the element will not move down. When adding a background to an inline element, you can use padding, but the background color will cover the surrounding elements.)
3. The width of the element is the image contained in the element. Or the width of the text, which cannot be set;*: Gaps will appear when there are "carriage returns", "tabs", and "spaces" between inline elements.
Solution: Write it on one line, without spaces, carriage returns or other symbols in the middle.Block elements
In html,
,