W3C home > Mailing lists > Public > www-html@w3.org > November 2000

Re: Attributes with no value

From: Clover Andrew <aclover@1VALUE.com>
Date: Thu, 9 Nov 2000 18:30:52 +0100
Message-ID: <5F78AA062F6AD311A59000508B4AAF6D092BDF@pcs02>
To: "'www-html@w3.org'" <www-html@w3.org>
pdf@bizfon.com <pdf@bizfon.com> wrote:

> Does anyone know if this is invalid HTML?

> <img alt src="someimage.gif">

The validator is correct, InterDev is wrong.

This stems from a common misunderstanding of what those single-word
attributes mean. It's really not a 'valueless attribute', but an
'attributeless value'. When you specify a single-word attribute,
you're specifying the value, not the attribute. Thus:

  <div center>Hello!</div>

is NOT equivalent to:

  <div center="">Hello!</div>

but in fact:

  <div align="center">Hello!</div>

and this is in fact a perfectly valid way of saying it, although
it isn't going to work in any mainstream browser. Obviously the
parser needs to know which attribute the value belongs to, so
this only works for values with fixed names, like 'center' in
this example. That's why the validator choked: it looked for
an attribute valid on <img> that could have the token 'alt' as
its value. Since none was found, it complained.

> Is there some fundamental principle of HTML that I'm missing?

Not HTML, but SGML, of which HTML is supposedly an application.
(Though very few browsers are actually proper SGML parsers.)
SGML has some tricky corners like this which XML was designed
to avoid and simplify.

HTML has made this particular problem quite sneaky, by giving
on/off attributes like, say, 'compact' the same name and
value. So:

  <dl compact>

is equivalent to:

  <dl compact="compact">

(Not <dl compact=""> in any case, whatever InterDev may think.)
This makes it *look* like the short version is specfying the
attribute name, but it's really the value.

> If not, then is it possible to modify the validator to see
> these as the same thing, therefore allowing my document to
> validate even after Microsoft has mutilated it?

They're not the same thing, I'm afraid. You'll have to work
around the problem. If InterDev has an XHTML output mode you
could try that (the short-form is not allowed at all in XML,
though I suppose that doesn't necessarily mean MS won't write
it). Otherwise, try putting a space as the value of the alt
attribute, I guess; should be mostly harmless

Andrew Clover
Technical Support
Received on Thursday, 9 November 2000 12:38:24 UTC

This archive was generated by hypermail 2.3.1 : Wednesday, 7 January 2015 15:05:55 UTC