HighDots Forums  

Setting an image as background to a table cell.

HTML Writing HTML for the Web (comp.infosystems.www.authoring.html)


Discuss Setting an image as background to a table cell. in the HTML forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Doug Laidlaw
 
Posts: n/a

Default Setting an image as background to a table cell. - 09-27-2005 , 02:54 AM






HTML validators say that "background" is not a valid attribute for a <td>
tag

I want to set an image as the background for one cell only, and to have the
cell content on top of it. If I can't use <td background="img
src=.."></td>, what is the correct method?

Some modern templates do it all with CSS, but that is getting a bit too deep
for my inexperience.

A URL is probably unnecessary, but here it is:
http://www.douglaidlaw.net/boykett/index.html

At the moment, it is a mess: too many tables within tables. The image of
the ship is the one in question. I want to re-do it from the bottom up,
and code the cell correctly in the process.

Doug.
--
Registered Linux User No. 277548. My true email address has hotkey for
myaccess.
There is nothing so strong or safe, in any emergency of life, as simple
truth.
- Charles Dickens


Reply With Quote
  #2  
Old   
Rincewind
 
Posts: n/a

Default Re: Setting an image as background to a table cell. - 09-28-2005 , 07:51 AM






On Tue, 27 Sep 2005 17:54:32 +1000, Doug Laidlaw wrote:

Quote:
At the moment, it is a mess: too many tables within tables. The image of
the ship is the one in question. I want to re-do it from the bottom up,
and code the cell correctly in the process.
You can say that again:-) No offence intended but if you are going to redo
the site/page then I would throw away NVU there website says <quote>The
current HTML typing rules were written with HTML mail generation very much
in mind; they are not optimal for web page writing, and we are aware of
this.</quote>.

You would be much better of with a plain text editor for writing the page,
a copy of Firefox for constant checking of what you are doing and bookmarks
to the W3c validation sites for HTML and CSS http://validator.w3.org/ and
http://jigsaw.w3.org/css-validator/, only after you have it looking as you
would like in FF check with IE.

Quote:
Some modern templates do it all with CSS, but that is getting a bit too deep
for my inexperience.
It's really not as difficult as you may think there a plethora of articles
on how to code with CSS and HTML a quick Google just returned "118,000,000
for CSS and HTML" a couple of useful ones are http://www.htmlgoodies.com/
and http://www.w3schools.com/default.asp and there is always this and other
newsgroups to help when you get stuck. You will find that it is much easier
to build a site when you separate the Style from the HTML.


Reply With Quote
  #3  
Old   
David Ross
 
Posts: n/a

Default Re: Setting an image as background to a table cell. - 09-29-2005 , 12:20 AM



Doug Laidlaw wrote:
Quote:
HTML validators say that "background" is not a valid attribute for a <td
tag

I want to set an image as the background for one cell only, and to have the
cell content on top of it. If I can't use <td background="img
src=.."></td>, what is the correct method?

Some modern templates do it all with CSS, but that is getting a bit too deep
for my inexperience.

A URL is probably unnecessary, but here it is:
http://www.douglaidlaw.net/boykett/index.html

At the moment, it is a mess: too many tables within tables. The image of
the ship is the one in question. I want to re-do it from the bottom up,
and code the cell correctly in the process.
You might prefer to avoid style-sheets, but that is the way to do
backgrounds.

In your header section (between <HEAD> and </HEAD>) establish a
style class named cell:

<style TYPE="text/css">
<!--
td.cell {background-image: url(abc.xyz);
background-position: center center }
-->
</style>

You might want some other properties besides these two. Note that
the commenting <!-- and --> are not really necessary, but I still
use it to highlight my style-sheets. It makes them easier to
find. abc.xyz is the file name within the same directory as the
Web page (unless you indicate otherwise via link statements or by
explicitly stating the full URL of the file. Note that the
extension (.xyz) must be for some graphical image file-type that a
Web browser can display (e.g., .gif, .jpg).

Then, on your table cell, use <td class=cell> in place of <td>
where you want a background image.

If you intend to float text in front of the image, make sure that
the text can be read. See <URL:http://www.oakparkfoundation.org/>
for the use of a faint watermark image. This image was carefully
designed to minimize interference with text; it's best seen at the
bottom of the page. However, the optimal situation would avoid any
background image.

--

David E. Ross
<URL:http://www.rossde.com/>

I use Mozilla as my Web browser because I want a browser that
complies with Web standards. See <URL:http://www.mozilla.org/>.


Reply With Quote
  #4  
Old   
twaddle
 
Posts: n/a

Default Re: Setting an image as background to a table cell. - 10-03-2005 , 12:54 AM



Doug Laidlaw wrote:
Quote:
Thanks. I normally use HTML Validator Lite.
Would that be "CSE HTML Validator ( htmlvalidator.com )? You should
know that it is not a validator, no matter what it calls itself. These
are.

http://validator.w3.org/
http://www.htmlhelp.com/tools/validator/


Quote:
It didn't pick up the particular error, but it has
before. (It did say that there was an error that the
Pro version would have identified.)
Sounds like CSE. It's possibly useful for the hints it gives, but it
does not validate the page, i.e. compare it to the doctype you declare
you use. You can see the effect that can have here:
<http://online.htmlvalidator.com/php/onlinevallite.php?url=http://w3c.org>

Hint -- that page does not have 20 errors.

--
twaddle



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.