Is it OK to have an empty anchor tag?

前端 未结 5 1176
庸人自扰
庸人自扰 2021-01-11 19:02

I know that I can do the following if I want to turn an image into a click-able link:



        
5条回答
  •  一向
    一向 (楼主)
    2021-01-11 19:24

    It is not OK at all, since it breaks fundamental accessibility principles. There is no way to specify alternative text for a background image, the same way you can and should specify it using an alt attribute in an img tag for a content image. See WCAG 2.0 Guideline 1.1.

    If you wish to change an image on mouseover, there are CSS and JavaScript techniques for that.

提交回复
热议问题