Keegan Brown Keegan Brown - 3 months ago 8x
CSS Question

padding not working in span tag

Ok, first off I want you all to know that I have tried using the

tag (though maybe incorrectly).

Is there something I'm doing wrong with the
tag? Or is there something I need to do differently altogether?

Here is my current code to create a space without

#beforeImage span {
padding: 40px;

<span id="beforeImage">text</span>


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>