label for[…] not recognised by IE8

后端 未结 5 1521
别跟我提以往
别跟我提以往 2021-01-25 13:10

I have the css below:

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

with the

5条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-25 13:46

    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 .

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

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

提交回复
热议问题