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

Accessibility: <a> tags without href #8409

Open
yawaramin opened this issue Aug 22, 2024 · 0 comments
Open

Accessibility: <a> tags without href #8409

yawaramin opened this issue Aug 22, 2024 · 0 comments
Assignees

Comments

@yawaramin
Copy link

Hi, there are a couple of <a> tags without href attributes in some of the templates. For example,

<a class="btn btn-danger" hx-post="{{ h.url_for('organization.unfollow', id=organization.id) }}" hx-target="#organization-info"><i class="fa-solid fa-circle-minus"></i> Unfollow</a>

As per https://accessibleweb.com/question-answer/link-element-still-accessible-without-href/

Links that are built with anchor elements (<a>) are not accessible without an href value. The href value determines what page or content a user will be directed to once the link is activated. If the href value is left blank, then the link may appear to be broken to users and may also cause confusing screen reader announcements.

Instead of using <a> for these buttons, the best option here would be to use a <form> tag:

<form method=post action=... hx-post=...>
  <input class="btn btn-danger" type=submit value=Unfollow>
</form>

This ensures two things:

  1. Accessiblity. Screen readers 'understand' and announce forms as actionable items on the page.
  2. Progressive enhancement. The follow/unfollow actions will work even with JavaScript disabled (they will just be normal form submits).
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