tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

important-vs-inline-001.html (1195B)


      1 <!DOCTYPE html>
      2 <html>
      3 <head>
      4  <meta charset="utf-8">
      5  <title>CSS Cascade: inline style loses to !important</title>
      6  <link rel="help" href="https://www.w3.org/TR/css-cascade-4/#cascade-sort">
      7  <link rel="author" href="mailto:sesse@chromium.org">
      8  <script src="/resources/testharness.js"></script>
      9  <script src="/resources/testharnessreport.js"></script>
     10  <style>
     11    .outer {
     12       opacity: 0.5 !important;
     13    }
     14  </style>
     15 </head>
     16 <body>
     17  <p class="outer" id="el">Test passes if this text is semi-transparent.</p>
     18 </body>
     19 <script>
     20 test(() => {
     21  el.offsetTop;
     22  assert_equals(getComputedStyle(el).opacity, "0.5", "style is set correctly");
     23 });
     24 test(() => {
     25  el.offsetTop;
     26  el.style.opacity = 0.75;
     27  assert_equals(getComputedStyle(el).opacity, "0.5", "!important has higher priority than adding inline style");
     28 });
     29 test(() => {
     30  el.offsetTop;
     31  el.style.opacity = 1.0;
     32  assert_equals(getComputedStyle(el).opacity, "0.5", "!important has higher priority than modifying inline style");
     33 });
     34 test(() => {
     35  el.offsetTop;
     36  el.style.opacity = null;
     37  assert_equals(getComputedStyle(el).opacity, "0.5", "!important has higher priority than removing inline style");
     38 });
     39 </script>
     40 </html>