<!DOCTYPE html>
<style>
  span { color: green; }
  div[dir="auto"]:dir(ltr) + span { color: red; }
</style>
<body dir="rtl" onload="window.oldColor = getComputedStyle(document.querySelector('span')).color; document.querySelector('[dir=auto]').setAttribute('dir', '')">
  <div dir="auto"></div>
  <span>This should be green</span>
</body>