W3C home > Mailing lists > Public > www-validator@w3.org > September 2007

Re: Problem with validator

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Tue, 18 Sep 2007 09:54:09 +0300 (EEST)
To: "webmaster@reflexprojects.net" <webmaster@reflexprojects.net>
cc: www-validator@w3.org
Message-ID: <Pine.SOC.4.64.0709180941330.1177@mustatilhi.cs.tut.fi>

On Mon, 17 Sep 2007, webmaster@reflexprojects.net wrote:

> I recently tried to validate my website using your service (it is coded
> in PHP, but that doesn't appear to be the problem), and it found 3
> errors.

Whether your page is PHP generated or not does not matter in validation; 
the validation does not even know that. But what _is_ important is the URL 
of your page.

> Upon looking at these, it was an error with using
> 'background="image"' functions within a <td> tag.

The background attribute is not allowed for <td> in any published 
specification. If you wish, you can use the validator on documents that 
contain proprietary attributes and elements, but then you need to specify 
a Document Type Definition (DTD) that contains them. This, however, is 
probably not productive here, since you only have three errors.

You might decide to ignore the errors, if you know what you are doing: 
you are using proprietary attributes that are supported by many browsers 
but not all and that do not belong (and most probably will never belong) 
to any HTML specification. So you could just check whether _all_ error 
messages relate to markup features that you consciously use against 
specifications.

> So, I asked for a tidy
> HTML version, and it generated one. I added this in, put the PHP coding
> in, but the backgrounds in the tables had gone.

Most probably Tidy cleaned away the attributes. Did it put some CSS with 
the same functionality? Hard to tell without a URL. (I don't use Tidy, 
since it does not work reliably - and it cleans things up in somewhat odd 
ways.)

> Does this mean I can't
> have table backgrounds for valid HTML?

Well, anyway the fact is that you cannot set background images for tables 
or cells using HTML attributes in a valid way (when "valid" means "valid 
with a DTD specified in HTML specifications") . This needs to be deduced 
from HTML specifications, though; you cannot logically derive it from the 
observations you mentioned. There simply isn't any markup in HTML for 
setting a background image except for the <body> element.

> And is there an
> HTML-friendly way to do it if possible?

I'm not sure I understand what you mean by "HTML-friendly", but you can 
set a background image in CSS, and it actually works a little more often 
than the proprietary way. Using a style sheet embedded in a style 
attribute (which is _not_ the recommended way - check CSS guides and 
tutorials for the recommended ways - but suitable for a quick demo), you 
could write

<td style="background-image: url(foo.gif);">

or, better (see CSS guides, etc.)

<td style="background: white url(foo.gif); color: black;">

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/
Received on Tuesday, 18 September 2007 06:55:03 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 10 December 2014 20:09:00 UTC