+ 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
3 Antworten
+ 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
+ 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.
+ 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