473,326 Members | 2,173 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Setting an image as background to a table cell.

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

Sep 28 '05 #1
5 3408
Doug Laidlaw wrote:
HTML validators say that "background" is not a valid attribute for a <td>
tag [...] If I can't use <td background="img
src=.."></td>, what is the correct method?
style="background: url('images/gipsy.jpg')"
Some modern templates do it all with CSS, but that is getting a bit too deep
for my inexperience.
Layout style should be done with style sheets.
A URL is probably unnecessary, but here it is:
http://www.douglaidlaw.net/boykett/index.html
I would not have bothered without an URL.
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.

Start by specifying HTML 4.01 Strict and resolving all those validation
errors. Oh, and provide a character encoding; a common one for English
(and many Europeans) is
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">.
UTF-8 is popular, too.

--
jmm dash list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)
Sep 28 '05 #2
Jim Moe wrote:
Doug Laidlaw wrote:
HTML validators say that "background" is not a valid attribute for a <td>
tag [...] If I can't use <td background="img
src=.."></td>, what is the correct method?

style="background: url('images/gipsy.jpg')"
Some modern templates do it all with CSS, but that is getting a bit too
deep for my inexperience.

Layout style should be done with style sheets.
A URL is probably unnecessary, but here it is:
http://www.douglaidlaw.net/boykett/index.html

I would not have bothered without an URL.
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.

Start by specifying HTML 4.01 Strict and resolving all those validation
errors. Oh, and provide a character encoding; a common one for English
(and many Europeans) is
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">.
UTF-8 is popular, too.

Thanks. I normally use HTML Validator Lite. 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.) I have a good handbook on
basic CSS and DHTML. Since I am strictly an amateur, and against too many
gimmicks, I haven't gone deeply into DHTML. I dislike sites that have
Flash just for the sake of having Flash. A method of covering all browsers
might however be desirable.

Doug.
--
Registered Linux User No. 277548. My true email address has hotkey for
myaccess.
It's all right letting yourself go as long as you can let yourself back.
-- Mick Jagger.

Sep 28 '05 #3
On Tue, 27 Sep 2005 17:54:32 +1000, Doug Laidlaw wrote:
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.
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.
Sep 28 '05 #4
Doug Laidlaw wrote:

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/>.
Sep 29 '05 #5
Doug Laidlaw wrote:
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/

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

Oct 3 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: MyndPhlyp | last post by:
I've been busting my head trying to figure this out for quite some time. With IE6 and NS7, no problems. I can simply code the HTML <img height="100%"> and be done with it. But NS4 and NS6 (and...
2
by: TAM | last post by:
Hi, I am using a table with height and width as 100%. I wish to use a background image of size W 62x H 314 pixels for one table cell. How do I make the background image stretch to fit the...
3
by: Gil | last post by:
Hello, I use VB.NET and have a series of linkbuttons that are inside individual <td>s. Like this: <td background="image.gif"><asp:linkbutton id="myID" runat="server"/></td> I would like...
4
by: Gary Hasler | last post by:
I have a full page of thumbnails linked to home plan pages. I'm adding a mouseover/mouseout effect to the table cells, plus a onclick event to permanently set the cell background to indicate the...
5
by: Derek Fountain | last post by:
I have a horizontal navigation bar, which is a single row table containing the right images. It "stretches" itself across the screen using a penultimate td like this: <td width="100%"...
2
by: Urbanposters | last post by:
Hi, i am hoping someone out there can help me with this, b/c i don't really know what is going on. i am working to put a background image in a cell of my table. i am using dreamweaver mx. the css...
2
by: mix2plix | last post by:
ok.. been bangin by brains the past few days with this one and decided to seek you'z help. so here ya go. based on the code below and this concept.. how should i proceed? I have a table of 4...
2
by: Jim | last post by:
How can I use JavaScript to change a background image in a table cell? Here's the code for the cell <td width="338" valign="top" background="../images/ LEC_Q1.jpg"><div...
4
by: Bob Altman | last post by:
Hi all, I posted an earlier question to the microsoft.public.inetserver.asp.general newsgroup asking how to set the background of a client-side table cell to a gradient, and I received this...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.