All I can imagine is that you have javascript that checks if the hash is empty. If so, it adds a class to the body tag called noHash. Then you can use the fact that there is a noHash class in your CSS rules.
if (window.location.hash.length <= 1) { document.body.className += " noHash"; }
Then your CSS might look like this:
div { background: blue; } div:target, body.noHash div { background: red; }
If there are any circumstances in which the user can add a hash value after the fact, then you may need to monitor this to make sure that the noHash class is deleted remotely.
Note: you do not need to add the class name to the body tag. You can add it to any parent object that covers all the objects that you want to affect.
jfriend00
source share