Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML5 allows omitting anchor href, html-proofer does not. #254

Closed
nkuehn opened this issue Oct 30, 2015 · 3 comments
Closed

HTML5 allows omitting anchor href, html-proofer does not. #254

nkuehn opened this issue Oct 30, 2015 · 3 comments
Assignees

Comments

@nkuehn
Copy link
Contributor

nkuehn commented Oct 30, 2015

Hi,
it would be good if html-proofer would allow omitting the href attribute on tags when doctype is HTML 5.
The spec ( http://www.w3.org/TR/html5/text-level-semantics.html#the-a-element ) explicitly allows it:

If the a element has no href attribute, then the element represents a placeholder for where a link might otherwise have been placed, if it had been relevant, consisting of just the element's contents.

When implementing javascript driven links this behavior currently forces to use either href="#" (which spams the history and jumps to the top of the page) or href="javascript:;", which is an ugly workaround) and ignore these via href_ignore.

@gjtorikian gjtorikian self-assigned this Nov 2, 2015
@gjtorikian
Copy link
Owner

I have implemented a fix for this: https://github.com/gjtorikian/html-proofer/compare/ignore-href-for-html5

I'm trying to think about how to best roll this out. I'm sure there are HTML5 users who want to be notified if an anchor is missing an href. I guess this will need to be a new option, but I'm not sure if it should default to following the spec or reporting the missing attribute.

@nkuehn
Copy link
Contributor Author

nkuehn commented Nov 30, 2015

+1, thanks! Behavior is a tricky thing indeed.

To me it looks like you're stuck between strictness (stricly adhering to the HTML spec) and backwards compatibility (existing users expect the proofer to find these things). Configuration hell ahead, a new HTML validation rule could be a way to do it. You seem to have plans to change the href_ignore parameter anyways, maybe that's a chance to add a kind of special value that instructs the validation to ingnore completely missing href, too.

@gjtorikian
Copy link
Owner

Yeah, my main thinking is to add a new strict option as a catch-all for these sorts of things. I would probably then drop check_html since that would also fall under "strict spec checking."

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants