Skip to main content
Logo Appt Light

Success Criterion 2.4.4 - Level A

Link Purpose (In Context)

Ensure links are clear without the surrounding content. Users of assistive technologies can request an overview of all links on the screen. It is important that the purpose of each link is clear. A common mistake is to name a link 'Read more'. Without the surrounding text it is not clear what you will read more about.

Impact

Assistive technologies can show an overview of all links on the screen. The purpose of each link should be clear immediately.

Check

Is the purpose of each link clear?

This can be tested without assistive technologies.

Solution

Mark links

On Android, links should be embedded inside an URLSpan.

To create text links, you can show the span in using the setText method of TextView. To support assistive technologies on lower version of Android, you need to call the ViewCompat.enableAccessibleClickableSpanSupport() method.

The helper method ViewCompat.addLinks() is also useful to automatically create accessible links.

val textView = TextView(this)

val url = "https://appt.org"
val link = "Appt"

val spannableString = SpannableString("Learn more about $link")

val index = spannableString.indexOf(link)
spannableString.setSpan(URLSpan(url), index, index + link.length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)

textView.text = spannableString
textView.movementMethod = LinkMovementMethod.getInstance()

ViewCompat.enableAccessibleClickableSpanSupport(textView)

Resources

Feedback?

Let us know!