Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / New
Stats: 3,154,256 members, 7,822,299 topics. Date: Thursday, 09 May 2024 at 09:44 AM

Difference Between Div And Span - Webmasters - Nairaland

Nairaland Forum / Science/Technology / Webmasters / Difference Between Div And Span (464 Views)

Difference Between <div> And <frame> / I Need Help On How To Use The Div Tag / Latest Wapka Div (2) (3) (4)

(1) (Reply)

Difference Between Div And Span by maekhel(m): 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/

3 Likes

(1) (Reply)

I Need Wp Plugins For My New Website / Is Alexa Ranking Updates Currently Down / Join Our Whatsapp Chat

(Go Up)

Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health
religion celebs tv-movies music-radio literature webmasters programming techmarket

Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10)

Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 10
Disclaimer: Every Nairaland member is solely responsible for anything that he/she posts or uploads on Nairaland.