View Full Version : Padding on span with bg colour (when turning to new line)

01-22-2008, 12:31 AM

If I have a span containing some text with a background colour, is there a way I can add padding to the ends of the lines so that if the text turns onto a new line there is still some padding between the end of the text and background colour?

You can see what I mean here (http://www.reefdoctor.org/index.php/rd/slideshow_test)

See the smaller type on white bg on the home page slideshow, even though I have padding set as:

padding:3px 0 3px 3px
the text is close against the edge of the bg on the left hand side.

Any ideas how I can add some padding to the left?


01-22-2008, 12:36 AM
I do not understand what you mean.

01-22-2008, 12:41 AM
Sorry, not very clear I know.
So, you see the photo slideshow. The smaller text overlaid on that with the white background. You see there is about 3px of padding on the left side of the first line (between "This is dummy..." and the end of the white bg)...well, it doesn't appear on the next line down, between "should..." and the end of the white bg)...

The second line is just turning naturally because of the width of the containing div.

I just want to avoid having zero padding on the end of those lines there.

Any thoughts?

01-22-2008, 02:01 PM
You can't add padding on an inline element. You put the padding on the span tags.

Add this code. This turns the span tags into block elements and will allow you to specify padding on them.

.fpss_introtext span.heading {
display: block;

.fpss_introtext span.fpss {
display: block;

01-22-2008, 02:25 PM
Thanks SoBrien,

Ah yes, got it.

Ok, what I want to do is to keep the white background behind the text extending just as far as the text goes, with just a bit of extra padding on the end, rather than displaying the chunk of smaller text as a block. Any solutions?