Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

image in specific table

Status
Not open for further replies.

celticking

Technical User
Feb 15, 2001
69
US
Can anyone advise how to display an image in a specifically named table using an external style sheet so as to prevent tiling?

ie <table width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot; name=&quot;Logo&quot;>

Thank you.
 
I know how to prevent tiling and to do this for a table in general. Just wondering how you define a specific table in CSS. Thanks.
 
There are a number of ways of doing this depending on what level of browser compatability is required. The more standards compliant method is to give the table an ID value and reference it in your css like this

<table id=&quot;table1&quot;>

and in css like this

#table1{background-image:url(&quot;myimage.gif&quot;); background-repeat:no-repeat;}

however this will only work for IE5+ and NS6 so for compliancy with version 4 browsers you are better to use a class like this

<table class=&quot;table1&quot;>

and in the css like this

table.table1{background-image:url(&quot;myimage.gif&quot;); background-repeat:no-repeat;}

or just

.table1{background-image:url(&quot;myimage.gif&quot;); background-repeat:no-repeat;}

however the latter would apply to any element with the class table1. although that wouldnt be a problem in a simple site in a large css site it may

hope this helps

rob
 
Thanks for the help. I'm a little confused though. Do i dispense with the name tag? When i define the class in my html, where is it placed exactly. I'm interpreting
<table class=&quot;logo&quot; width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;> I'm sure this is incorrect though. Thanks again.
 
It doesnt matter in which order the tab is.

<table name=&quot;table1&quot; class=&quot;myTable&quot; width=&quot;100%&quot; border=&quot;0&quot; cellpadding=&quot;0&quot; cellspacing=&quot;0&quot;>

This is a correct statement. CrazyBoyBert did misexplain
something though about ID's though. You dont give a table
an ID as you give table a name. You create a ID for example:

#myID1{color: red; background-image:url(&quot;myimage.gif&quot;); background-repeat:no-repeat;}

#myID2{color: blue; background-image:url(&quot;myimage.gif&quot;); background-repeat:no-repeat;}

These ID's (they are ID's because of the #) can be taken
on by objects by refering to them in the ID=&quot;&quot; subtag.

Basically, it's a difference of GIVING a name to an
object and ASSIGNING an ID.

I hope this helps, BobbaFet

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top