Forum Moderators: open

Message Too Old, No Replies

validator.w3.org

no background attribute for <td> element?

         

Catnip

10:50 pm on Jun 11, 2003 (gmt 0)

10+ Year Member



Here is the error:

Below are the results of attempting to parse this document with an SGML parser.

1. Line 60, column 73: there is no attribute "BACKGROUND" (explain...).
...align="center" bgcolor="#333399" background="/images/top_left.gif">

If line 60 is a problem why would line 62 not come up with an error? Plz help my brain is mush.

<table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
59: <tr>
60: <td width="10" align="center" bgcolor="#333399" background="/images/top_left.gif">
61: <img src="/images/spacer.gif" alt=" " width="8" height="20" border="0"><img src="/images/spacer.gif" alt=" " width="1" height="21" border="0"></td>
62: <td width="735" align="center" bgcolor="#333399" background="/images/top_left.gif">
63: <a href="/vacation-rentals/" class="tnl">View Properties</a>
64: ¦&nbsp;<a href="/why/" class="tnl">Why Join?</a>

?
:(

outrun

10:55 pm on Jun 11, 2003 (gmt 0)

10+ Year Member



Your not allowed to have a background image in an <td> element.

regards,
Mark

Catnip

11:07 pm on Jun 11, 2003 (gmt 0)

10+ Year Member



outrun,

Well how else could I do it? It seems to work in all my browsers even NN 4.79 and that browser is usually a pain in the a$$.

Thanks for the fast reply

Catnip
:)

grahamstewart

11:19 pm on Jun 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The 'correct' way to set a background image is via CSS - either inline using the style="" tag or by using an external stylesheet.

e.g.


<td style="background: url(images/top_left.gif) no-repeat bottom right">

or in a CSS file..


td.topleft {
background: url(images/top_left.gif) no-repeat bottom right;
}

Not sure how well this will work in Netscape 4 but do you really care? (it is buggy as hell and represents less than 1% of the market).

outrun

11:24 pm on Jun 11, 2003 (gmt 0)

10+ Year Member



<added> dont you hate it when somone posts before you and yes this will work in netscape 4.79</added>
You could try the css fix.

<td style="background-image:url(image.gif)"> or if you have just one image for every instance of your td element, define this in your style sheet.

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

regards,
Mark

g1smd

11:32 pm on Jun 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



>> If line 60 is a problem why would line 62 not come up with an error? Plz help my brain is mush. <<

For some types of error, the validator reports only the first occurrance rather than every one. I have no idea why it does this, and have almost come to regard it as a bug.

pageoneresults

11:36 pm on Jun 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



For some types of error, the validator reports only the first occurrance rather than every one.

This used to drive me absolutely crazy a couple of years ago when I first started validating. You'd clear up one error on line 50. Then another would appear at line 54. Clear that up and then another at line 58. Then it dawns on you that the validator only detects the first instance and is expecting you to correct all other instances.

Catnip, here is a thread that was started by tedster a while back that will alert you to the most common errors you'll run into and how to correct them...

Common Validation Errors [webmasterworld.com]

grahamstewart

11:40 pm on Jun 11, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Its a pretty common approach - many compilers do the same sort of thing. It stops you getting swamped by hundreds of error messages at one time.

Imagine Catnip had a table that was 5 columns by 50 rows - that would generate 250 identical error messages so you wouldn't spot any other errors that you also might want to fix.

tedster

3:59 am on Jun 12, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Many people have tripped over the background attribute in tables and table cells. Rightly stated, it was an "extension" to standard HTML, but it was never approved. Even the MS and Netscape browsers that offered support were really weird for a while.

Older IE blows up on jpg images, older Netscape ignores some gifs. Eventually their support stabilized, but as I said, the attribute has NEVER been included in the W3C standard.

Here's some W3C correspondence on the issue from 2002.

Netscape and MS browsers support a variety of "extensions" to HTML that
are not part of any W3C DTD. Valid HTML that declares a W3C DTD must
not, therefore, use them. The 'background' attributes are one example.

If you want to maximise accessibility, you would be far better served to
use HTML 4.01 Strict and CSS.

W3C Reference [lists.w3.org]

Katie_Venra

3:07 am on Jun 13, 2003 (gmt 0)

10+ Year Member



I remember when i ran my site through the validator a few months back, i almost started crying when i seen all the errors...HUNDREDS of them...

I got it down to about 100 odd, then gave up...i have never been back to that place since. Seems to me you cant have a nice visually layed out site without the validator tearing the code apart and making you revert a plain white HTML page with plain Times New Roman text on it with no images and no links...thats the only time ive been able to make the validator happy :(

grahamstewart

3:17 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you cant have a nice visually layed out site without the validator tearing the code apart

The secret is: HTML is NOT for visual layout! :)
Its for marking up the structure of the document.

CSS is what you use for the style and layout.

Take a look at [csszengarden.com...]
Its written in valid XHTML 1.0 Strict (and valid CSS, and its accessible) and it looks lovely.

Not a "Plain times new roman" in sight!

Validation is becoming increasingly important as more and more browsers and document types are appearing.

<spooky_voice>Ignore it at your peril...</spooky_voice> ;)

g1smd

10:06 am on Jun 13, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



I took a look recently at a single page with over 800 errors. It turned out that there were only five types of error, so it was actually quite easy to fix them all. For example, there were over 300 URLs that simply required that the ampersand be escaped by changing every & to be &amp; instead.

If there are errors in your code then other people viewing your site may see a completely broken page. It is important to get rid of as many errors as possible. I am guilty of using a few browser specific tags and attributes from time to time, but there are never any tag typos, nesting errors, tags closed in the wrong order, unclosed tags, unquoted attribute values, or other such errors with the logic or structure of the document.