plz explain the use of span and div in easy words... | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

plz explain the use of span and div in easy words...

solve the problem

3rd Jul 2018, 7:11 AM
Ahmad Mughal
Ahmad Mughal - avatar
4 Answers
+ 9
Hello, Ahmad Mughal ! The main difference between these two tags - one of them <span> is a line item, and the other <div> is a block element. This means that using the <div> tag, you can select a piece of information (text, pictures, etc.) into a separate block and set certain style properties to it. The <div> block always has indents: before <div> and after </div>. And with the help of the <span> tag, you can select a string, word or a single letter inside other tags, and then set a separate style for the selected text. And for <span> you can not set the width and height attributes, as well as for any other line item. https://www.sololearn.com/learn/HTML/1034/
3rd Jul 2018, 7:17 AM
Alexander Sokolov
Alexander Sokolov - avatar
+ 4
Hii Ahmad ! Simply <div> is the block level element while <span> is the line level element.That means <div> can contain a no. of tags inside it to enhance their beauty by using color,height or width like attributes. But <span> can contain only a string or a word or a letter and not the whole tag.Span is also used to enhance the buty but inside the text. Hence <div> create a block while <span > is used inside a line.
4th Jul 2018, 5:23 AM
Shivanshi
Shivanshi - avatar
+ 3
thanks sir...
3rd Jul 2018, 7:21 AM
Ahmad Mughal
Ahmad Mughal - avatar
+ 2
Thanks shivanshi i understand ur answer very well...
5th Jul 2018, 3:31 AM
Ali Hassan
Ali Hassan - avatar