What is the difference between <div> and <span>? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 6

What is the difference between <div> and <span>?

17th Apr 2017, 5:14 AM
vismay thakkar
vismay thakkar - avatar
6 Answers
+ 17
Div is a block-element, used like a container. Span is a inline-element, used for inline text. -------------------------------- <div> <h2> Lorem Ispum </h2> <span> Lorem Ipsum la la la </span> </div> ~~~~~~~~~~~~~~~~~~~~~~~~~~~ <span> Lorem Ipsum la la la </span> --------------------------------
17th Apr 2017, 5:17 AM
Maz - avatar
+ 9
Adding to @Maz, <span> tag is meant for applying inline styles to the content that is otherwise not possible. <span style="color:red:font-weight:bold">Important Text</span>
17th Apr 2017, 5:38 AM
देवेंद्र महाजन (Devender)
देवेंद्र महाजन (Devender) - avatar
+ 6
span is inline element div is a block element
17th Apr 2017, 5:16 AM
Yaroslav Pieskov
Yaroslav Pieskov - avatar
+ 6
Try running a code using div and span. You will get the difference by seeing the output.
12th Aug 2018, 11:52 AM
Mitali - avatar
+ 3
<div> for container (block) <span> for texts (inline) But <div> is an older element of HTML. In HTML5, there is already: <main> <article> <section> <header> <nav> and many more which is more readable and easy to understand than <div>.
13th Aug 2018, 3:48 PM
Email Not Activated