html tags are divided into two types: inline elements and block-level elements. First, let’s understand the concepts of inline elements and block-level elements:
Block-level elements: Generally, it is a container for other elements, which can accommodate inline elements and other block-level elements. Block-level elements reject other elements in the same row as them. You can set the width (width) and height (height) attributes. Block-level elements in normal streams will be placed vertically. Common block elements are div Inline elements (inline elements): Inline elements can only accommodate text or other inline elements and are descendants of block-level elements. They allow other inline elements to be on the same line as them and cannot set height and width. A common inline element is a.According to the concept of block-level elements, we can understand that block-level elements have line breaks before and after, which is equivalent to adding a <br> tag before and after the element. We can think of block-level elements as a block or a rectangle, so block-level elements can set the height-width attribute
example:
css file:
Copy the code