Get the App
SLTechnology News&Howtos  ›  Development  › 

What is the difference between div and span in HTML

Shulou Source: shulou.com Published: 2022-06-01 07:47:17 10月22日 Update

This article mainly introduces the relevant knowledge of the difference between the use of div and span in HTML, the content is detailed and easy to understand, the operation is simple and fast, and it has a certain reference value. I believe you will gain something after reading this article on the difference between the use of div and span in HTML. Let's take a look.

HTML part

WeChatManager

$(document) .ready (function () {

$(document) .keyup (function (event) {

If (event.keyCode==13) {

$.ajax ({

Type: "POST"

Url: "ok.php"

Data: "code=" + $("# in") .val ()

Success:function (msg) {

$("ul") .append ("" + $("# in") .val () + "); / / output the input to the interface

$("ul") .append ("" + msg+ ""); / / get the return value and output

$("# in"). Val (""); / / clear the input box

$("# text") .scrollTop ($("# text") .scrollTop () + 32); / / pull the scroll bar to the bottom to display the input box

}

})

}

})

$("# in") [0] .focus ()

})

WechatDos

Welcome...

Login:

CSS part

@ charset "utf-8"

Body {

Background-color:#396DA5

Margin:0px

Padding:0px

Color:#fff

Font: Microsoft Yahei

Font-size:14px;}

.window {

Border:6px#cccoutset

Width:680px

Height:442px

Background-color:#000

Position:absolute

Top:40px

Left:68px

Overflow:hidden}

.title {

Background-color:#08246B

Padding:2px;}

# text {

Background-color:#000

Border-top:#cccoutset2px

Height:420px

Overflow-y:scroll;}

Ul {

Margin:0px

Padding:0px

List-style:none;}

Input {

Background-color:#000

Border:0

Color:#fff

Outline:none

What they have in common:

DIV tags and SPAN tags deal with some content as a whole, such as hiding and moving as a whole. Something like a box. Doing so can simplify the code and improve efficiency.

Differences:

1. Div puts the content into a rectangular block, and moving it at will will affect the layout. On the other hand, span only defines the content as a whole and does not affect the layout and display.

2. Div is generally used for typesetting, while span is generally used for local text styles.

/ * font-size:12px;*/

Width:100%}

This is the end of the article on "what is the difference between the use of div and span in HTML". Thank you for reading! I believe you all have a certain understanding of the knowledge of "what is the difference between the use of div and span in HTML". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Content whole knowledge input layout tags articles parts influence movement output different different points things code values common ground blocks just local Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Information Shulou Tech Info Shulou Technology macOS Huawei