2

I've found such code in html5boilerplate:

/**
 * Address styling not present in IE 7/8/9, Firefox 3, and Safari 4.
 * Known issue: no IE 6 support.
 */

[hidden] {
  display: none;
}

What address? What does it affect? Elements with attribute hidden like following example?

<div hidden></div>
4

3 回答 3

4

Yes, exactly like your example. The selector will match any element with a hidden attribute (there's an implied universal selector before the attribute selector).

The hidden attribute is a new addition to the HTML specification, and is therefore not supported in older browsers. By adding that rule to your stylesheet, you effectively polyfill the native behaviour of that attribute (which is, fairly obviously, to hide the element, similar to setting display: none).

The "known issue" in IE6 is caused by the fact that it doesn't support attribute selectors.

于 2013-01-22T09:05:34.700 回答
3

hidden is an attribute in HTML5

Read Detailed description here. Also read a good explanation here

The comment would seem to suggest that that CSS solution is to address those browsers which are not compatible with the new hidden behavior by default

于 2013-01-22T09:05:18.337 回答
2

You can also create your own attributes using the prefix "data-". For example Jquery Mobile uses it.

Example :

Your HTML

<div data-role="header" data-position="top">
   // content here
</div>

Your CSS

[data-role=header] 
{
     font-family:arial;
     font-size:20px;
}

[data-position=top]
{
     top:5px;
}

A good explanation is available here.

The W3C documentation

于 2013-01-22T09:13:55.480 回答