Forum Moderators: not2easy

Message Too Old, No Replies

Table border images

How do I change this inline CSS to an external file?

         

WebWalla

6:17 pm on Nov 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have created a table with inline CSS for the border images, e.g...


<td style="background-image:url(http://www.example.com/images/top.gif)"></td>

I just can't get this to work when putting it in an external CSS file.

I realise that I could get rid of the table entirely and put the whole thing in CSS but I'm simply not fluent enough in CSS to do this.

So is there a way of getting this to work with an external CSS file, while keeping the table?

Thanks.

pageoneresults

6:26 pm on Nov 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



<td style="background-image:url(http://www.example.com/images/top.gif)"></td>

I realise that I could get rid of the table entirely and put the whole thing in CSS but I'm simply not fluent enough in CSS to do this.

Same here. But, I think I can help.

So is there a way of getting this to work with an external CSS file, while keeping the table?

I believe you could just set up a generic class that has a background image. Something like this...

.tdbg1{
background-image:url(http://www.example.com/images/top.gif);
}

And then assign that class to the <td> like so...

<td class="tdbg1">&nbsp;</td>

You may have to use some additional background positioning rules but the above would be a start I think. :)

P.S. Be sure to include the &nbsp; if its an empty <td>&nbsp;</td> element.

rocknbil

10:40 pm on Nov 7, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



It's probably not necessary, but you **should** be able to eliminate the full url. "/" implies "start at the domain root," so it doesn't matter where in your domain you store the css, at root, in a directory or subdirectory, this should do the same thing:

background:url(/images/top.gif) top left repeat-x;

This is particularly useful if your site accesses this style sheet via https as well as non-https.