[...]的标签未被IE8识别 [英] label for[...] not recognised by IE8

查看:102
本文介绍了[...]的标签未被IE8识别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下css:

span label[for=Length]
{
width: 90px; 
display: block;
text-align:right; 
margin-top: 2px;
margin-right: 5px;
}

使用html:

<span><label for="Length">Length:</label></span>
<span><input type=text id="Length"></span>

它在IE8中不起作用。 标签[for = ...] 无法识别。任何解决方法?

It doesn't work in IE8. label[for=...] is not recognised. Any workaround?

谢谢。

UPDATE

我的问题出了问题所以现在我更新了。有解决方案?谢谢!

I do a mistake in my question so now I updated. Any solutions? Thanks!

推荐答案

IE 8(或IE 9)不支持怪癖模式。这就是为什么在Quentin的答案中添加一个合适的doctype声明,修复了IE 8上的问题。最简单的文档类型是<!doctype html>

IE 8 (or IE 9 for that matter) does not support attribute selectors in Quirks Mode. This is why adding a suitable doctype declaration, as suggested in Quentin’s answer, fixes the issue on IE 8. The simplest doctype for the purpose is <!doctype html>.

在IE 7上,没有任何帮助,因为它只是缺乏支持,而不是在怪癖模式中掩盖它。

On IE 7, nothing helps, as it simply lacks the support, instead of having it masked out in Quirks Mode.

标签元素上使用 id 属性更安全,例如< label id = foo for = Length> ,并使用 id 选择器,例如。这些选择器适用于所有支持CSS的浏览器。

It is thus safer to use an id attribute on the label element, e.g. <label id=foo for=Length>, and use an id selector, such as #foo, in CSS. Such selectors work on all CSS-enabled browsers.

这篇关于[...]的标签未被IE8识别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆