Ok, first off I want you all to know that I have tried using the <span></span>
tag (though maybe incorrectly).
Is there something I'm doing wrong with the <span></span>
tag? Or is there something I need to do differently altogether?
Here is my current code to create a space without <br></br>
:
#beforeImage span {
padding: 40px;
}
<span id="beforeImage">text</span>
span won't have padding because it is an inline element by default, so set inline-block or block.
Since span tags are inline, not block elements. They can only take margin left and right, not top and bottom. See this related post, Margin-Top not working for span element?
We can use the padding-left property in a <span> element to add spaces. For example, inside the HTML body, type the text of your desire. Where you want to add the blank space, create a <span> element and apply the style in it. Set the padding-left property to 30px .
The reason vertical padding /margin does not work with spans is that it's an inline element.
2 things to fix:
you were applying the CSS to span
of an ID selector, but you were using a span
with an ID selector in your HTML.
span
won't have padding
because it is an inline element by default, so set inline-block
or block
#beforeImage {
padding: 40px;
display: inline-block; /* or block */
/* demo */
background: red
}
<span id="beforeImage">Foo bar</span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With