How to set width of spans without text using php?
This is what I have tried:
for($i = 0; $i < 256; ++$i)
{
echo '<span id="red_' . $i . '" style="width:10px;height:10px;background-color:red;"><span>';
}
The spans are not displaying. If I add text to spans then they are displaying but it’s width is equal to the width of text. I want the width to exactly 10px.
2
Answers
span tag isn't closed as
</span>
The element
<span>
is not ablock
element but aninline
one. Therefore it does not have a width. The simplest way to set it as ablock
or at least aninline-block
element.or
The difference is
inline-block
does not change to a new line, butblock
changes to a new line.