简体   繁体   中英

How are unknown/invalid pseudo-classes in CSS selectors handled?

What does this CSS selector should point to? AFAIK :bar pseudo-class does not exist...

.Today_s_foo:bar
{
 font-size: 21px;
 font-family: "Ubuntu";
}

Per the current specification for parsing errors in selectors: "the entire rule in which the selector is used is dropped." See also this part of the spec for an example of the consequences.

By "rule" it means every property setting inside the {brackets} will be ignored if any part of the selector is parsed as invalid.

Normally it should invalidate the whole rule, which may be important when using multiple selectors in one rule, see simple example: http://jsfiddle.net/S56xM/

HTML:

<div>Hello!</div>

CSS:

div, div:foobaresque { font-size: 100px; }

You will see that the div { font-size: 100px; } div { font-size: 100px; } "sub-rule" is not applied, even if our mind tells us it would be applied.

Correction applied

The rules in .Today_s_foo will not be set on any working browser.

I thought it was listed as an Unrecommended hack on http://www.javascriptkit.com/dhtmltutors/csshacks3.shtml

IE

.Today_s_foo:IE6 /* IE6 hack */

but its not there.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM