Links containing a Label tag are not clickable on IE

别来无恙 提交于 2019-12-02 01:09:56

问题


I've come across an unusual situation with general IE compatibility.

The following link is unclickable in IE, but fine on everything else (I've tried IE8 onwards):

<a href="http://bbc.co.uk"><label>text</label></a>

Whilst the above doesn't work, swapping the label for a div or a span is fine.

Is there any sensible way to make this style of markup work in IE with minimal changes. I'd like to keep the label tag if at all possible.


回答1:


Doesn't using a label inside an a tag invalidate the html as a label is interactive content? You'd be better served using a span for this.




回答2:


Labels are for form elements. In this context, they are being used incorrectly. Anyone using a screen reader will be confused by the markup, since upon "seeing" a label they are expecting a corresponding form element. A span element would be better suited, and would work across all browsers with minimal changes, since you're simply changing <label> for <span>.



来源:https://stackoverflow.com/questions/20147215/links-containing-a-label-tag-are-not-clickable-on-ie

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!