"Jeff Thies" <> wrote:
> I can't tell you how many forms that I've seen with spaces in the form
> names.
But that's a different issue. You asked about name and id attributes in
img elements.
The name attribute is actually very polymorphic - i.e., it has different
rules in different elements, or the name attributes in different elements
are really _different attributes_ which just incidentally share the same
name.
In _form fields_, the name attribute may (and often needs to) contain
just about anything. Spaces are no problem.
In <img> and <form> elements, the name attribute is not needed except for
certain modes of JavaScript coding and is not even allowed in all
versions of HTML. What you can put there if you use it depends on
JavaScript more than anything else.
The id attribute must by definition have a unique value of type ID, which
sets very strict syntax rules.
The name attribute in <a> may contain any string from the HTML
perspective, but since it is used for the purpose of using it in a
fragment identifier, it's best to stick to simple syntax, e.g. no spaces.
In theory, if you use <a name="foo bar">, you can then use
href="#foo%20bar" (i.e., with the space as URL encoded), but this is
clumsy, odd-looking, and not supported by all browsers.
--
Yucca,
http://www.cs.tut.fi/~jkorpela/
Pages about Web authoring:
http://www.cs.tut.fi/~jkorpela/www.html