Next, learn about the production of HTML web pages when developing with div+css, especially the difference and usage of div and span in tag application. When a novice uses web standards (div css) to develop a web page, the first question they encounter is what is the difference between div and span, when to use div and when to use span tags The following is an introduction to the system defaults when no CSS style is set for the development web page. 1. Differences and characteristics between DIV and SPANDifference between div and span The position occupied by div is one line,
2. Span tag summaryWhen developing web pages, you can use both div and span, and it can usually be understood that there is no difference. But please note that div occupies one line, while span does not. The width of span is as wide as the content. Generally speaking, div is used for web page layout, p tag is used for paragraph content, and span is used to set the style or color of part of the paragraph content.
3. Expansion and improvementThe span inside the div does not need to name the CSS selector pseudo-class, as shown below If the class of div is yangshi, then set the CSS attribute for the span inside. The code is as follows 4. Demonstration effect of legend exampleAnalyzing the above figure: we can conclude that span does not need to be named with a pseudo-class name, and can directly use CSS inheritance attributes to set the CSS style for span. The original style of the div is to set the text to blue, but the style of the span is set to red through inheritance. I hope the CSS cases summarized on the divcss5 website are helpful to you. Here is a technical article explaining the differences and usage of div and span. Q: What is the difference between DIV and SPAN?Answer: Solution: The biggest feature of DIV and SPAN elements is that no formatting or rendering is performed on the objects within the elements by default. Mainly used to apply style sheets. The most obvious difference between the two is that DIV is a block element, while SPAN is an inline element (also translated as an embedded element). Specific steps: 1. Block elements are elements that start rendering on a new line, while inline elements do not need to start on a new line. You will have a more vivid understanding by testing the following code: Because of the special nature of DIV and SPAN elements, they are generally used to apply style sheets, such as defining them as layers with CSS. What needs to be distinguished is the difference between block elements and inline elements, as well as the conversion between the two. DIV specifies the container for rendering HTML. |
<<: A brief analysis of SQL examples for finding uncommitted transactions in MySQL
>>: Docker container monitoring principle and cAdvisor installation and usage instructions
This article records the installation and configu...
Table of contents Start and stop Database related...
This article summarizes various ways to implement...
Because the docker daemon needs to bind to the ho...
If you want to insert 5 records into table1, the ...
Original configuration: http { ...... limit_conn_...
1. Add the viewport tag to the HTML header. At th...
Table of contents 1. Foreign key constraints What...
The examples in this article run on MySQL 5.0 and...
Overview I believe we often encounter such scenar...
This article example shares the specific code of ...
Sometimes we may encounter such a requirement, th...
As a programmer who has just learned Tomcat, this...
Table of contents 1. Background 2. Local custom i...
MySQL executes SQL through the process of SQL par...