Span Width Not Working
Aug 4, 2022
Span is an inline element. It has no width or height.
<div id='box' style='
background: black;
border-radius: 15px;
top: 4%;
left: 2%;
width: 96%;
height: 94%;
position: absolute;
'><span style='color:white; width:100%; text-align:right;'>test</span></div>
Things like this won’t work. You need to change the style of a span
to something like below.
<div id='box' style='
background: black;
border-radius: 15px;
top: 4%;
left: 2%;
width: 96%;
height: 94%;
position: absolute;
'><span style='color:white; width:100%; display:inline-block; text-align:right;'>test</span></div>
And it worked!
According to Basheer AL-MOMANI (css — Does height and width not apply to span? — Stack Overflow): You could turn it into a block-level element, then it will accept your dimension directives.