[whatwg] Attributes vs. Elements

whatwg at robertdot.org whatwg at robertdot.org
Mon Mar 12 16:23:51 PDT 2007


ddailey wrote:
> The ease of using DOM methods to find tags, as opposed to attributes,
> tends  to suggest that all things having href's should be easily
> findable by  script. <a> works nicely for that, but would the
> availability of a  document.links array then include all things with
> href's?

In JavaScript, document.links would work, though I've been indoctrinated
into the modern DOM camp and like to use
document.getElementsByTagName("a").  I try to avoid DOM 0 style
collections, but for things like form validation, I end up using the
.elements collection frequently.  I'm sure I could adjust my way of
thinking if I needed to.

My gripe, however, was with CSS attribute selectors.[1]  I didn't really
make that clear.  IE 6 doesn't do them.  However, as someone pointed out,
something like td:link would work.  I wouldn't need td[href] to get at
"all tds with hrefs".  Assuming that is true, and it had support from the
4 major browsers, the href-on-all-attributes would work pragmatically.

If it would make sense semantically / ideologically, I'm still unsure.  I
don't know if the existence of the anchor element was lack of foresight or
if it has a real semantic meaning like em or strong that is independent of
the href.

[1] http://www.w3.org/TR/CSS21/selector.html#attribute-selectors





More information about the whatwg mailing list