CSS Tutorial

CSS Style

CSS Layout Style

CSS Float Style

CSS Reference

CSS element[attr|=value] Selector


What is element[attr|=value] Selector?

CSS [attr|=value] Selector matches all elements whose attribute value beginning with exactly "value" word immediately followed by "-".

Browser Compatibility

  • Google Chrome 2+
  • Mozilla Firefox 3+
  • Internet Explorer 9+
  • Opera 9.5+
  • Safari 1.3+

Note: Here details of browser compatibility with version number may be this is bug and not supported. But recommended to always use latest Web browser.

Syntax

This general syntax of element[attr|=value] Selector,

[attr|=value] {
	property: value;
	property: value;
	...
}

Example:

Select every element whose hreflang attribute value beginning with exactly "en" word immediately followed by "-".

<style type="text/css">
a[hreflang|=en] {
    background:yellow;
}
</style>
</head>
<body>
    <a hreflang="en" href="#">English International</a><br />
    <a hreflang="en-US" href="#">English US</a><br />
    <a hreflang="IN" href="#">Google</a><br />
    <a hreflang="fr" href="#">Frances</a>
</body>

Run it...   »

Example Result: