Links do not have a discernible name как исправить

Lighthouse suggesting to fix my a href text

I have a html like that

<a href="https://twitter.com/@some-name-here" target="_blank" rel="noopener" class="social-icon twitter grayscale"></a>

What is really happens here is I just displaying the image inside a href by using css class:

.social-icon.twitter {
  background: url('../images/logo-twitter.png') no-repeat center center;
}

I can’t do <a....>Twitter</a> as in that case the displayed text will destroy the view.

I can’t think of anything else like just putting a span with a text inside my a and make it hidden e.g <a....><span class="hide">Twitter</span></a> but wonder if there is any proper solution?

Any recommendations on that?

Henrik Andersson's user avatar

asked Aug 4, 2018 at 8:16

Sergino's user avatar

For accessibility reasons (required for screen readers) links must contain a text or have description in aria-label attribute. In many use cases like yours you don’t want to add any text in a link, but instead use as image or any graphic element wrapper.

Fix it by adding aria-label="Twitter" to your a element, like

<a href="https://twitter.com/@some-name-here" aria-label="Twitter" target="_blank" rel="noopener" class="social-icon twitter grayscale"></a>

answered Aug 6, 2018 at 20:58

Binyamin's user avatar

BinyaminBinyamin

7,38510 gold badges60 silver badges82 bronze badges

2

If want to implement this in react app then, We need to add aria-label property to <a> tag.

Before:

<a href={`https://${ this.props.info }`} target="_blank" rel="noopener noreferrer">
   <i className="fa fa-circle fa-stack-2x"></i>
   <i className={ `fa fa-${ this.props.icon } fa-stack-1x fa-inverse` }></i>
</a>

After:

<a href={`https://${ this.props.info }`} aria-label={`${ this.props.name }`} target="_blank" rel="noopener noreferrer">
   <i className="fa fa-circle fa-stack-2x"></i>
   <i className={ `fa fa-${ this.props.icon } fa-stack-1x fa-inverse` }></i>
</a>

answered Oct 6, 2018 at 4:41

KARTHIKEYAN.A's user avatar

KARTHIKEYAN.AKARTHIKEYAN.A

17.5k6 gold badges116 silver badges132 bronze badges

For SlickNav
The solution is quite simple. Just add title to the element of the Javascript file which has aria-haspopup=»true» and tabindex=»0″ attribute. Add title like title=»Anything» in above-mentioned line. It will solve the problem.
Working example is Oceanspace

For other similar issues you have to add title attribute to the respective anchor element

Problem was here

answered May 20, 2021 at 14:20

hrushikesh thule's user avatar

May 22, 2023

Google Chrome’s DevTools includes a resource for auditing general website performance and potential accessibility issues. 

That resource, Lighthouse, is not perfect — no automated tool can guarantee conformance with the Web Content Accessibility Guidelines (WCAG), the international standards for digital accessibility. If you’re using Lighthouse, it’s important to understand the limitations of Chrome DevTools

With that said, Lighthouse is easy to use, free, and accurate at diagnosing certain issues. After running an audit, you might run into a message that reads: 

“Links do not have a discernible name. Link text (and alternate text for images, when used as links) that is discernible, unique, and focusable improves the navigation experience for screen reader users.”

Here’s what the message means (and how to fix it). 

Why Lighthouse Reports a “Links Do Not Have Discernable Name» Error

The error message indicates a potential failure of WCAG 2.1 Success Criterion (SC) 2.4.4, “Link Purpose (In Context).” This criterion simply requires the text of (or associated with) a hyperlink to describe the purpose of the link.

You’ll have to look at the element in question to determine whether the error is accurate — but if it involves a hyperlink, it probably needs to be addressed. 

Here’s why discernible names are important: Not all internet users perceive content visually. Some people use screen readers (software that outputs text as audio or braille) or other types of assistive technology.

If a link doesn’t have a unique, descriptive name, these users won’t understand what happens when they activate the link. That can be frustrating, especially when the linked component is part of a process (such as a checkout process on an eCommerce website). 

Fixing the “Links Do Not Have a Discernible Name» Error

Fortunately, it’s fairly easy to give your hyperlinks accessible names. 

Lighthouse will identify each element that fails this check. Your first step is to double-check your HTML syntax. From there, you’ll use one of the following techniques to remediate the issue: 

Simple Text Hyperlinks

For a simple text hyperlink, the text within the HTML tags should indicate the purpose with simple, descriptive language (learn why “click here» isn’t enough context for hyperlinks). 

Since many screen reader users “jump” around to hyperlinks (rather than reading through every word of your content), the best practice is to determine whether people could understand the link’s purpose simply by reading the link text on its own. If possible, the link text should be similar or identical to the title of the linked page. 

For more guidance, read: Quick Guide to Accessible Hyperlinks

Hyperlinked Images

If you’re using an image as a hyperlink, there may not be any on-screen text. Instead, you’ll write alternative text (also called alt text) that describes what happens when the link is activated. 

Some quick tips:

  • Screen readers will identify the image as a link, so you don’t need to use language like “this is a link» or “link goes to» — simply provide the same information that visual users could understand from looking at the image. 
  • Keep the alt text concise. Describe the image with the first words that come to mind. The description should include any text that appears in the image. 
  • In many cases, the text alone may be enough to describe the purpose of the link, so you don’t need to describe the rest of the image. For example, if you’ve got an image with a big, red button that reads “visit our store,” the alt text might simply read: “Visit our store.’”

For more guidance, read: 8 Common Image Alt Text Mistakes to Stop Making.

Discernible Links for Complex Content

The issue gets slightly more complicated if you’re using a complex or dynamic element. 

If the element cannot be defined with native HTML, you may need to use WAI-ARIA (Web Accessibility Initiative — Accessible Rich Internet Applications, also referred to simply as ARIA) to define the name and purpose of the link via the aria-label or aria-labelledby properties. 

However, ARIA is powerful stuff: If you misuse ARIA markup, you can actually make your website less accessible for assistive technology users. Wherever possible, you should use native HTML instead — if you decide to use ARIA, test it carefully before publishing your changes.

For more guidance, read: 4 Questions to Ask Before Using ARIA

Remember, automated audits aren’t enough for WCAG conformance

Google Lighthouse can tell you whether links have names, but it can’t always determine whether those names are helpful. 

For example, if you have a text hyperlink that reads “get started,” you may pass a Lighthouse audit, but you haven’t fulfilled WCAG SC 2.4.1 — your users won’t know what happens when they click the link.

Like all automated accessibility tools, Lighthouse isn’t great at handling issues that require human judgment. It can’t determine whether your ARIA markup is perfect, it may miss “Skip to Content» links, and it won’t be able to identify misleading subheadings or page titles.

You can certainly use Lighthouse for quick checks, but you’ll need to perform more thorough tests throughout development. At the Bureau of Internet Accessibility, we use a four-point hybrid testing methodology that pairs powerful automation with guidance from human experts. We believe this approach provides the best path to digital compliance.

To build an effective and sustainable digital accessibility strategy, get started with a free WCAG website accessibility analysis or download our eBook: The Ultimate Guide to Web Accessibility.

A common error in PageSpeed Insights / Lighthouse what about the user experience / accessibility. “Links do not have a discernible name“.

In the present scenario, the error is returned because the links on the icons do not have a description. If links on icons are used for social networks or other profiles, they must contain a descriptive label, named “aria-label“.

On the subject VoiceMeks, the error most often occurs at the links “Author Box” from the end of the articles..

Links do not have a discernible name
Link text (and alternate text for images, when used as links) that is discernible, unique, and focusable improves the navigation experience for screen reader users

Fix Voice Theme / Links do not have a discernible name

The simple solution is to add the label: aria-label="Name" .

In “author box” for Voice (theme by Meks), I solved by a change in the line 73 from template-parts/author-box.php where I added the label aria-label.

<a href="<?php echo esc_url($social_meta ); ?>" aria-label="<?php echo esc_attr( $soc_name ); ?>" target="_blank" rel="noopener" class="fa fa-<?php echo esc_attr( $soc_id ); ?>"></a>

Original line:

<a href="<?php echo esc_url($social_meta ); ?>" target="_blank" class="fa fa-<?php echo esc_attr( $soc_id ); ?>"></a>

This error that can depunct the score in Lighthouse, it is possible that other WordPress themes developed by Meks.

After making the above changes on all the icons that have links, Links do not have a discernible name will no longer be present in Lighthouse.

Passionate about everything gadget means, operating systems, WordPress, JavaScript, I am writing with pleasure on stealthsettings.com from 2006 and I like to discover new things about macOS operating systems, Linux, Windows, iOS yes Android. I’m successfully exploring WordPress, WooCommerce and web server optimization for online stores and press websites.

Problem mobile : Links do not have a discernible name
Link text (and alternate text for images, when used as links) that is discernible, unique, and focusable improves the navigation experience for screen reader user div#primary > main#main > section#widget_videos_block-1 > a.more-videos
<a class=»more-videos label» href=»https://example.com/?filter=latest «>

Hi I would like to know how to solve this problem :Links do not have a discernible name , but I don't know how to do it given my inexperience thanks

asked Dec 18, 2022 at 10:32

Fabry's user avatar

1

Load 7 more related questions

Show fewer related questions

У меня ошибка:

Links do not have a discernible name Link text (and alternate text for
images, when used as links) that is discernible, unique, and focusable
improves the navigation experience for screen reader users. Learn
more.

Я попытался включить aria-label, но это не сработало. Это вызывает ошибку:

<a href = "https://...../demo/index.php/Products/Description/Apple-Cinema-27/products_id-1" c = "Apple Cinema 27">
  <img src = "images/products/130_61ajN-dgGxL._SL1000_.jpg"
       alt = "Apple Cinema 27"
       title = "Apple Cinema 27"
       width = "130"
       height = "130"
       class = "media-object img-fluid">
</a>

Спасибо

Я потерялся в контексте ошибки, полагаю, что это простая утилита. Если да, то какой?


— stealththeninja

19.11.2018 05:29

@stealththeninja: Я предполагаю, что это Маяк. Ссылка «Узнать больше» указывает (или должна указывать) на developers.google.com/web/tools/lighthouse/audits/… Тем не менее, нигде не предлагается добавить метку aria, поэтому я скептически отношусь к тому, читали ли они документ.


— BoltClock

19.11.2018 05:41

Кажется странным, что альтернативный текст здесь не рассматривается — возможно, Lighthouse проявляет осторожность и предполагает, что не все AT увидят или объявят альтернативный текст изображения.


— BoltClock

19.11.2018 05:45

Опубликованный пример кода действителен и соответствует требованиям WCAG. Если вы получаете эту ошибку, чего-то еще не хватает. Для <a> не нужен видимый текст или aria-label, если есть вложенный <img> с атрибутом alt. Атрибут alt становится «доступным именем».


— slugolicious

19.11.2018 08:14

Toor - Ангулярный шаблон для бронирования путешествий

Раскрытие чувствительных данных

Раскрытие чувствительных данных

Все внешние компоненты, рассмотренные здесь до сих пор, взаимодействуют с клиентской стороной. Однако, если они подвергаются атаке, они не…

Разница между тегами Br и Wbr в HTML 5

Разница между тегами Br и Wbr в HTML 5

В целом, оба тега <br> и <wbr> имеют свои уникальные цели и функциональные возможности, и их использование зависит от конкретных требований к дизайну…

HTML И VS CODE Для Веб-разработки

HTML И VS CODE Для Веб-разработки

Прежде чем начать кодировать html в «VS CODE», мы должны сначала создать папку и назвать ее x.html, здесь я принимаю x как имя файла, который мы…

Как использовать WAI-ARIA

Как использовать WAI-ARIA

В моем текущем новом проекте почти все компоненты не учитывают веб-доступность. Моя нынешняя компания — это стартап, поэтому они не заботились о…

Статическая веб-страница, созданная с помощью CSS и HTML - до и не до.


Ответы
2

Возможно, атрибут alt нуждается в небольшой модификации. Атрибут alt должен определять назначение или цель ссылки. Вот очень упрощенный пример:

    <a href = "contact.html">
        <img src = "contact.png" alt = "Return to the contact page">
    </a>

Следовательно, вам может не понадобиться атрибут aria-label.

Попробуйте использовать aria-label = «….» — это альтернативный текст для изображения.

<a
   href = "https://...../demo/index.php/Products/Description/Apple-Cinema-27/products_id-1"
   data-c = "Apple Cinema 27"
   aria-label = "yourdescription">

Другие вопросы по теме

Понравилась статья? Поделить с друзьями:
  • Как найти телеграмм аккаунт в телеграмме
  • Как составить родословную семьи по фамилии
  • Вопросы по предмету как найти работу
  • Как составить текст рассылки по смс
  • Как найти процент роста между двумя значениями