nathanford / data-href

data-href - Put an href on it.
155 stars 20 forks source link

Pointless? #1

Open jpdevries opened 10 years ago

jpdevries commented 10 years ago

It is valid to wrap any tag in an anchor so I don't understand the point of using JavaScript for this.

paulirish commented 10 years ago

Was going to ask the same thing.

pazguille commented 10 years ago

"Please, don't hurt the web."

paulirish commented 10 years ago

@jpdevries can you reword this issue title to be a little bit nicer? :) "HTML makes this script mostly redundant" perhaps

nathanford commented 10 years ago

This is a good question. My feelings aren’t hurt (though the title could be more descriptive).

I built this because the pattern used in the README.md is not currently valid in HTML5. The spec states that while you can use block-level anchors, you still cannot nest an anchor within an anchor:

http://dev.w3.org/html5/markup/a.html

This makes the tags and author links in my pattern invalid. So I thought it might be fun to resurrect a feature of XHTML2 that I really liked – adding an href to any element:

http://xhtml.com/en/future/x-html-5-versus-xhtml-2/#x2-cool-hyperlink

As for breaking the web: I am in no way suggesting using this in place of an anchor link. I am merely using it to extend the hit area for mobile, etc. You will notice my example still has an anchor within the h1, as you would expect.

This should all be in the README.md, I know. I will be amending it soon.

dieulot commented 10 years ago

For anchor withins an anchor, you may use CSS’s positioning to achive the same effect. Apple used to do this on some of their promo pages. Not sure if that works in all cases though.