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)
Let's take a look at the problem of VScode re...
So we introduce an embedding framework to solve th...
After the form is submitted, the returned HTML pag...
Adding the extra_hosts keyword in docker-compose....
Table of contents 1. Introduction 2. Several ways...
The implementation principle of chain programming...
Preface During my internship at the company, I us...
Table of contents Create a global shared content ...
1. Clarify the design direction <br />First,...
This article example shares the specific code of ...
Dark background style page design is very popular...
Table of contents Global Registration Partial Reg...
1. flex-direction: (direction of element arrangem...
The specific code for implementing the retractabl...
Table of contents 1. Realistic Background 2. Agre...