• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 284
  • Last Modified:

Background image only in body

Hello experts.
I have a background image in the page properties but i don't want this image where my table is.
Here is the code.
Any help?

<style type="text/css">
<!--
body {
	background-image: url(img/bg_schraffur.gif);
}
-->
</style>
 
<table width="955px" height="1000px">
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>

Open in new window

0
Panos
Asked:
Panos
  • 3
  • 3
  • 2
  • +1
3 Solutions
 
mudbuggleCommented:
You have to set the table background or else it defaults to transparent. You can do this for all tables.
table {
      background: #FFFFFF;
}

or you can set a class so you can specify difforent colors and backgrounds for different tables. Personally I prefer using classes.
http://www.tizag.com/cssT/class.php
0
 
GeekyDesignerCommented:
Hello,

In your CSS, add a background color to the table:

<style type="text/css">
<!--
body {
        background-image: url(img/bg_schraffur.gif);
}

table {
        background-color: #FFFFFF;
}
-->
</style>

I hope this helps!

~GD
0
 
biyikCommented:
Hi!
Background image of body covers all page. However, you can add a background color or image to tables to create the effect you want:
<table width="955px" height="1000px" bgcolor="#000000">
But keep in mind, the bgcolor attribute has been deprecated in HTML 4.0 and XHTML. You can create the same effect by css:
<table width="955px" height="1000px" style="background-color:#000000">
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
GeekyDesignerCommented:
Hello Mudbuggle,

If you just use the coding above that I posted, adding the background-color for the table to the CSS , this is correct way of doing it, meeting today's web standards.

~GD


0
 
mudbuggleCommented:
Hello GD,

I can agree, hence the reason I posted exactly what you posted before you posted it. Also, web standards aside there are many ways of obtaining the same result, it is wise to be versed in as many of these as possible.

~Mud
0
 
GeekyDesignerCommented:
Mudbuggle,

I was confused for a minute...I am just seeing your posting now. We must have posted the same answer at the same time. I was referring to the depreciated tag bgcolor that was suggested.

~GD
0
 
mudbuggleCommented:
GD,

Cool Deal!

~Mud
0
 
PanosAuthor Commented:
Thank you all for your help.
regards
panos
0
 
PanosAuthor Commented:
Hi again
Why do i have still the image behind the table?
Here is the code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-7" />
<title>Untitled Document</title>
<style type="text/css">
body,td,th {
      font-family: Verdana, Geneva, sans-serif;
      font-size: 12px;
      background-image: url(../img/bg_schraffur.gif);
      background-repeat: repeat-x;
}
.table {
      width: 955px;
      height: 1000px;
      background-color: #FFF;
      border: thin solid #000;
}
</style>
 
</head>
 
<body>
 
 
<table border="0"  align="center" cellspacing="0" class="table">
  <tr>
    <td width="50%"></td>
    <td width="20%"></td>
    </tr>
    <tr>
    <td width="20%"> </td>
    <td width="20%"> </td>
  </tr>
</table>
 
 
</body>
</html>
And the screenshot
screen.gif
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now