There are two types of html tags, inline elements and block-level elements. First, let's understand the concepts of inline elements and block-level elements: Block-level elements: Generally, they are containers for other elements. They can hold inline elements and other block-level elements. Block-level elements exclude other elements from being on the same line as them. They can set width and height attributes. Block-level elements in the normal flow will be placed vertically. Common block elements are "div" Inline elements (inline elements): Inline elements can only contain text or other inline elements. They are descendants of block-level elements. They allow other inline elements to be located on the same line with them. The height and width cannot be set. 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 them, 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 height and width attributes example: Copy code The code is as follows:#div1{ width:200px; height:200px; background:#666 } div2{ width:200px; height:200px; background:#F00 } html file: Copy code The code is as follows:<div id="div1"> div1 Block-level elements exclude other elements from being placed on the same line as them </div> <div id="div2"> div2 Block-level elements exclude other elements from being placed on the same line as them </div> Display effect: ![]() The two div elements are not on the same line According to the concept of inline elements, we can understand that there are no line breaks before and after inline elements. We can think of an inline element as a line, so it cannot have height and width attributes set. Block element tags address - address Inline element a - anchor point |
<<: Solutions for high traffic websites
>>: CSS achieves the effect of hiding the scroll bar and scrolling the content (three ways)
This article uses examples to explain the concept...
Table of contents The basic principle of MySQL ma...
Table of contents background What is the Metavers...
Preface Regarding the use of MySQL indexes, we ha...
I started working on my final project today, but ...
Preface Today, when I was designing a feedback fo...
Table of contents 1. Basic principles 2. Specific...
Without relying on JavaScript, pure CSS is used t...
Download image Selecting a MySQL Image docker sea...
This article shares the detailed steps of install...
Find the problem I recently migrated the storage ...
1. Refine the selector By using combinators, the ...
Ubuntu 18.04 installs mysql 5.7 for your referenc...
What is Redis Cluster Redis cluster is a distribu...
This article shares the specific code of js to ac...