+ 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 ответов
+ 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