Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

A question about accessibility - using an image as a link...

Featured Replies

Hello everyone. I am using an image as a link and I want to make sure it is accessible.

So I found this but in their example they have an onClick() event.

My question is. Do I need 

role="link"

if I have this as my code?

            <a href="#startseite">
              <img
                src="img/startseite.svg"
                alt="Startseite"
                title="Startseite"
              />
            </a>

Many thanks for your help!

No.

but do you really need an image to link back to the homepage?

Accessibility is poor and Google prefers text. Remember that internal linking is a powerful SEO technique if done correctly.

  • Author

 

              <img
                src="img/startseite.svg"

That is a font I could not find anywhere, so I recreated it as a picture.

Is that a bad idea?

And it needs no role?

Thanks for your help!

 

 

Edited by silly.questions

The font should be the same as the rest of the site. Why make it so complicated.

You don't need the role.

Just have a styled text button. Keep it simple.

  • 1 year later...

No, you don’t need role="link" here.

Your code is already accessible because you’re using a native <a> element, which has the link role by default.

Why this is correct:

<a href="..."> is automatically announced as a link by screen readers

The alt="Startseite" text provides an accessible name for the link

Keyboard navigation (Tab + Enter) works out of the box

role="link" is only needed when you’re not using a semantic link, for example:

A <div> or <span> acting like a link

JavaScript-only click handlers (onClick) without an <a>

So your current markup is already the best practice. Just keep the meaningful alt text, and you’re good.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.