terribleMia’s avatarterribleMia’s Twitter Archive—№ 6,181

      1. More cascading "gotcha's" with CSS variables: html { color: var(--text-color, red); } p { --text-color: blue; } p color is still red, because we inherit the *computed* value red from html, not the specified value var(--text-color, red).
    1. …in reply to @TerribleMia
      Changing the variable does not cause the inherited value to re-calculate. We can do that by using e.g.: * { color: var(--text-color); } /* re-calculate everywhere */ html { --text-color: red; } p { --text-color: blue; }
  1. …in reply to @TerribleMia
    Doesn’t need to be the universal selector, as long as it matches the places you need to re-calc. Which also doesn’t have to be the same place you define the variable… But the re-calc location has to have access to the updated variable - directly or by inheriting.