Jump to content

Help with CSS and Tables


drake3713
 Share

Recommended Posts

Hey everyone this is my first post on the forums, I just joined yesterday. Unfortunately my first post is about a problem I'm having with a website I'm working on. Can someone please describe how to use CSS to make a background image for a <td> of a table. Right now I'm simply using <td background="mypic.png"> but when I run this through the HTML Validator it gives me an error message about an unknown attribute (background). This is my only error message so as soon as I fix this, my site is valid. I've tried reading the tutorials but I can't seem to find what I'm looking for. Thanks in advance.

Link to comment
Share on other sites

Use the below code:

<style type="text/css">td {  background: url(#) center;}</style>

http://www.w3schools.com/css/css_background.aspReplace # with the url of the image. Remember, that CSS code will target ALL <td> tags on your page. If you only want one background on a <td> tag, then you need this:

<style type="text/css">.bg {  background: url(#) center;}</style><table>  <tr>	<td class="bg"><p> </p><td>  </tr></table>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...