[thelist] incorrect use of ID parameter?

j.d. welch so.there at showtunepink.com
Tue Feb 11 23:57:01 CST 2003

On Wednesday, February 12, 2003, at 12:44 AM, Miles Tillinger wrote:

> After running some of my HTML through validator.w3.org I have realized
> that
> I've been using the ID parameter incorrectly:
> e.g.
> Creating a CSS class for TD:    TD#CLASSNAME { font-weight: bold; }
> And applying it to a TD: <TD ID="CLASSNAME">hello world</TD>

> So when I run this through the validator it picks up a heap of
> duplicate ID
> parameter values.  I haven't noticed any bad effects of this so far,
> it just
> means that running my pages through the validator is a bit of a
> hassle!  Am
> I going to experience other problems doing things this way?

indeed it will, and they are valid errors, even if browser X renders it
'correctly.' ids are _not classes_ and for elements that appear _once_
in the page (http://www.w3.org/TR/REC-CSS2/selector.html#id-selectors).
  since presumably the td element is used multiple times, consider using
a class instead, i.e td.classname {font-weight:bold}.  the end effect
will be the same (or better),  you'll be conforming to the spec, and
the validator will be happy.


    J.D. Welch			|    so.there at showtunepink.com
    graphic designer    	|    http://www.showtunepink.com
    web developer       	|    http://kitschparade.ath.cx
    i'm available -> http://www.showtunepink.com/resume.html

More information about the thelist mailing list