Why i cant use span in the place if div??? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 4

Why i cant use span in the place if div???

In the given code if I am using span the allign center in css doesn't work Can u explain me why Please take this code as reference https://code.sololearn.com/WEalY3pFoCSU/?ref=app

30th Mar 2020, 3:25 AM
meet khurana
meet khurana - avatar
3 Respostas
+ 7
meet khurana first off let's start out saying that div tags are a block tag and span is an inline tag AĀ blockĀ element defaults to being the width of its container. It can have its width set using CSS, but either way it is a fixed width. AnĀ inlineĀ element takes its width from the size of its content text. https://stackoverflow.com/a/7757048/7218253
30th Mar 2020, 4:14 AM
BroFar
BroFar - avatar
+ 6
Because "<span>" is an inline element ,where <div> is block level , as Inline element they take width equal to it's content. So you need to use display:block; on span which makes span behave as block level element Inline elements cannot contain any block level elements.
30th Mar 2020, 10:01 AM
AHMED ETAHRY
AHMED ETAHRY - avatar
+ 1
Because "<span>" is an inline element ,where <div> is block level , as Inline element they take width equal to it's content. So you need to use display:block; on span which makes span behave as block level element
30th Mar 2020, 4:09 AM
Sudarshan Rai
Sudarshan Rai - avatar