[whatwg] href attribute
Matthew Raymond
mattraymond at earthlink.net
Sun Mar 11 14:16:33 PDT 2007
Andrew Fedoniouk wrote:
>> This is not a definition of the <a> element. In fact, <a> is defined
>> as a anchor, not a hyperlink.
>
> I think "hyperlink" is better in any sense
> than "anchor" as a designation of this entity.
Why? A hyperlink is a relationship BETWEEN to anchors. It can't be an
element any more than a journey can be considered a place.
> I beleive that you and me have different interpretation of
> the term 'semantic'.
>
> For my semantic any HTML element that has
> "href" attribute is not anyhow different from the <a> element
> with href.
What you're creating is a new attribute that happens to have the same
name as the HTML 4.01 |href| attribute, not an extension thereof. The
fact that it could be implemented in a manner identical to <a href> is a
function of implementation, not semantics.
> If I see <li href="..."> I recognize that this is a list item that
> leads somewhere.
That's not saying much, because you already know how to use <a> and
are familiar with its attributes.
> Exactly (and even better) as <li><a href="...">...</a></li>
No it's not, because if I want to move the anchor out of the list,
I'd have to create a new container element in your markup, whereas the
HTML 4.01 equivalent requires a mere cut and paste (or perhaps a
drag-drop, depending on your editor).
> For different tools it also does not matter what to use:
>
> getElementsBySelector(":link") or
> getElementsBySelector("a:link") or
> getElementsBySelector("[href]") or
> whatever.
If you want to use the Selectors API:
| document.matchAll("[href]")
However, my point was never that you couldn't find a newly defined
attribute with a newly defined DOM API...
> In any case not all <a>'s are hyperlinks so
> for your meaning of semantic they should also not be
> automatically hyperlinks (or anchors if you wish).
An <a> element is always an anchor. It's simply not specified whether
or not it's a source or a destination. No element can be a hyperlink, by
the definition you provided in your earlier post, because a hyperlink is
a relationship between anchors.
> I am pretty sure that existence of 'href' attribute is
> what creates semantic meaning of <a> for you.
The |href| attribute doesn't define anchors. It defines the
relationship between those anchors. It does imply that the anchor is a
source, but the actual anchor semantic is at the element level.
> So why <a> cannot be <b href> or <c href>?
1) It makes the markup brittle when editing.
2) It makes markup harder to read by:
a) Forcing you to look for an attribute that can very in position
relative to the start of the element tag instead of a letter
that's the very first character in the element tag.
b) Forcing you to look for the starting tag in order to determine if
an ending tag ends an anchor for a hyperlink.
3) It's not compatible with legacy browsers.
4) It causes confusion because authors might infer the meaning of the
attribute based on the element it's declared on.
5) It may be non-trivial to add to some browser implementations.
More information about the whatwg
mailing list