Keegan Brown Keegan Brown - 1 year ago 115
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>

Answer Source

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>

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download