Can I put padding-top in a span tag?

I need to add padding to the top of an image in a div:

<div class='cellimg' style='padding-top=$paddingtop'>$thumb</div>

The $thumb is a thumbnail image that varies in height. The $paddingtop is the padding that I add to the top of the image to push the image to the middle of the DIV. How do I write the CSS so the padding-top variable properly addresses the $thumb? The above does not work. I suppose I can use a span tag for $thumb, but don’t know the right syntaxt. I suppose padding-top can’t be used for a span inline element anyway.

Steve H

The above does not work.

That’s because you have the wrong syntax:


It should be:


i.e padding-top:10px; not padding-top=10px;

There’s no need for a span and as you point out a span is an inline element and padding-top would not work as you expect because the image would likely push out of the current line but the padding on the span probably won’t.

Thank you! I’ll have to try something else then.

Thank you! I’ll have to try something else then.

Hmmm - what do you mean?

Just apply the padding to the div as I have shown above. Or do you mean something else?