问题
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