₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,326,361 members, 8,426,235 topics. Date: Saturday, 13 June 2026 at 10:19 PM

Toggle theme

Difference Between Div And Span - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersDifference Between Div And Span (578 Views)

1 Reply

Difference Between Div And Span by maekhel(op): 11:02am On Jan 31, 2015
I will be doing a very brief but concise difference between div and span. I some of you might have asked questions like, whats the difference between div and span? Whats the effect of using each? When should I use each of them? I will try as much as possible to give answers to the questions in the best understanding way I can.
Div stands for division and it was introduced basically for doing layouts. The div tag is a block level element and must be used only in places where block level elements are legal. As a block level element, div creates a line break. The content of the div does not determine the width of the div but the width size given to it through CSS or it will take the full width of the seen if none is given.
Span on the other hand is an inline level element and as an inline level element, it must only contain other inline elements. Span does not create line break. The width of span depends upon the content of itself.
Let me explain all this with some examples to make things more clearer.
<!DOCTYPE html>
<html>
<head>
<title>TutorialsLodge | Difference Between Div And Span</title>
</head>
<body>
<div style="background-color: red">This is a DIV</div>
<p></p>
<span style="background-color: blue">This is a Span</span>
</body>
</html>
You should get a screen similar to below.
<!DOCTYPE html>
<html>
<head>
<title>TutorialsLodge | Difference Between Div And Span</title>
</head>
<body>
<span><div>This is a DIV</div></span>
</body>
</html>
The code snippets above is wrong because I placed a block level element within an inline level element.
Conclusion
I hope this post has been helpful in differentiating between div and span. Kindly drop your comments, questions, views and suggestions in the comment box below.
source: http://tutorialslodge.com/difference-div-span/
1 Reply

Difference Between <div> And <frame>I Need Help On How To Use The Div TagLatest Wapka Div234

Shineadverts Pay Publishers, Blog Website OwnerHow To Edit A Webpage Live On Your Pc Adress BarBuilding The Spirit Of An Entrepreneur