CSS [attr~=value] Selector

What is CSS [attr~=value] Selector?

CSS [attr~=value] Selector matches all elements whose have attr attribute and value contain like "value".


This syntax apply to select every element whose have attr attribute and value contain like "value".

[attr~=value] {
  property: value;
  property: value;


Select every element whose have whose have href attributes and value contain like "http://www.way2tutorial.com" to apply CSS style.

<!DOCTYPE html>
  <title>CSS [attr~=value] Selector</title>
  <style type="text/css">
    a[href~="http://www.way2tutorial.com"] {
  <a href="http://www.way2tutorial.com">Way2Tutorial</a>

  <br />

  <a href="http://webtuts.way2tutorial.com">WebTuts</a>

Run it...   »

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.