Background image in a cell.

admin

Administrator
Staff member
I have a background image within a table cell as follows:-<br />
<br />
<td width="750" height="126" colspan="27" valign="top" background="welcomeimages/bannerrepeat.gif">&nbsp;</td><br />
<br />
However, after validating my page for transitional 4.01 it says the attribute has been depreciated. What should I use instead of the background attribute ?<br />
<br />
Thanks<br />
<br />
Toot<!--content-->You could try CSS, Toots. I think I've got the code right.<br />
<br />
<script type="text/css"><br />
td.withimage { <br />
background: white url ("welcomeimages/bannerrepeat.gif"); <br />
background-repeat: no-repeat;<br />
background-position: center; <br />
}<br />
</script><br />
<br />
And in the cell where you want the image, you write <td class="withimage">.<br />
<br />
It's a good idea to specify a background colour. Just in case the image doesn't show up. And you can, of course, adjust the repeats and/or position to suit.<br />
<br />
Does that help?<br />
<br />
Peg<!--content-->Originally posted by Pegasus <br />
<br />
<script type="text/css"><br />
td.withimage { <br />
background: white url ("welcomeimages/bannerrepeat.gif"); <br />
background-repeat: no-repeat;<br />
background-position: center; <br />
}<br />
</script><br />
<br />
<br />
almost peg, should be :<br />
<br />
<style type=...></style><br />
<br />
you had a bit or shorthand there, why not make it all shorthand:<br />
<br />
{ <br />
background: #ffffff <br />
url("welcomeimages/bannerrepeat.gif") no-repeat center center }<br />
<br />
:D<!--content-->*lol* You're right, Leo. Can we blame it on the fact that I was doing a mad scramble through the CSS printout to find all the pieces? <sigh> I keep forgetting how to create a specific file for one element. The "td.withimage" isn't in the same section as "background-".<br />
<br />
Peg<!--content-->Originally posted by Pegasus <br />
*lol* You're right, Leo. Can we blame it on the fact that I was doing a mad scramble through the CSS printout to find all the pieces? <sigh> I keep forgetting how to create a specific file for one element. The "td.withimage" isn't in the same section as "background-".<br />
<br />
Peg <br />
<br />
lol, yeah i think we can ;) , easy mistake to make though :)<!--content-->couldnt the background attribute work too?<br />
<br />
<br />
jw.<!--content-->Originally posted by xxnfg618xx <br />
couldnt the background attribute work too?<br />
<br />
<br />
jw. <br />
no, because it is deprecated and shouldn't be used.<!--content-->Well it does work, but it wont' validate.<!--content-->Many thanks for the help. I must admit that I'm really having fun trying to get pages validated 100% for transitional 4.01. Does anyone else have an addiction for 100% validation ? <br />
<br />
Also regarding the td.withimage, I assume I may rename the .withimage to anything I like ?<br />
<br />
Cheers<br />
<br />
Toot<!--content-->I've gotten more addicted to xhtml 1.0 transitional....well maybe addicted is a little strong.<!--content-->i think my page validates;)<!--content-->Originally posted by tootsweets <br />
Also regarding the td.withimage, I assume I may rename the .withimage to anything I like ? With anything that isn't currently a command, yes. I'm not sure how it would react if you had a class of 'img' or 'background'. Better safe than bald? *g* Tearing your hair out trying to find out why it doesn't work?<br />
<br />
I can't say as I'm keen to have my pages validate 100% according to the W3 standards. It's nice, I suppose, but with the 'standards' changing so often, I'll settle for being 'mostly validated'. <br />
<br />
To be honest, I can't see any reason for a number of the changes. This 'change everything using CSS' idea just doesn't sit well. Why should I have to learn a second programming language to change the appearance and layout of HTML? What's the purpose of having HTML then, if everything gets done in CSS? It makes sense, I admit, when you're repeating things like font faces and colours, but for one-time changes like a single red horizontal rule in an entire site? No, it doesn't make sense to me. Shorten the HTML, yes, by all means, but don't choke it off entirely. At the rate they're going, it won't be long before HTML disappears entirely. Except for maybe <html></html>, <head>(and title/meta tags, maybe)</head> and <body></body>. <br />
<br />
<sigh> I know, I know. Nothing stays the same forever, but still.... <br />
<br />
Peg<!--content-->oh, my bad, I thought that would work, haha<br />
<br />
<br />
^^ referered to scoutt<!--content-->
 
Back
Top