7

I am trying to modify my site so that it complies with the WCAG standards. I am generating links with no content but these are marked as errors.

I have been redirected to the fix by the editor(H91) but it does not really solve my case.

How should I approach this?

Example of current link:

 <a name="dbcaddi:hasSubjectDescription"></a>
Matthieu FAURE
  • 383
  • 3
  • 11
Potney Switters
  • 2,902
  • 4
  • 33
  • 51
  • *Why* don’t your `a` elements contain any content? What is their use? – unor May 28 '13 at 18:56
  • They act as ajax links. It would be nice to rephrase these elements instead of using other type elements. This is option B because then I will need to also edit the ajax. – Potney Switters May 29 '13 at 07:15
  • So they contain content (`content`) but have no `href` attribute? Maybe you should include an example in your question. – unor May 29 '13 at 08:13
  • I though I posted here. No the links I present are . This does not comply with WCAG, so I get an error. – Potney Switters May 29 '13 at 14:17

3 Answers3

4

If your link is meant to be an anchor, just add an id attribute with same value as name.

If it is meant to be an actual link, that a user may activate, you need to provide it a "link text", i.e. some descriptive text between <a> and </a>.

This is required for accessibility because some users (e.g. screen-reader users) list all links of a page to quickly understand it.

As an application developer, if your link is empty you should remove it, and when needed (JS event or so) add the whole complete and functionnal stanza: <a href="...">blabla</a>

(By the way, if you use some JS/AJAX, you should give a review at WAI-ARIA concepts).

Matthieu FAURE
  • 383
  • 3
  • 11
3

if you are using an icon as your content then just add a screen reader only span inbetween your elements.. this will then pass the test

<a> <span class="sr-only">some text that relates to your link</span> <i class="icon"> </i> </a>
72GM
  • 2,926
  • 3
  • 27
  • 33
-7

Eventually I ended up to add and hide this inside the link:

 <span>&nbsp;</span>
Potney Switters
  • 2,902
  • 4
  • 33
  • 51