<!DOCTYPE html>
<style>
::selection {
background-color: rgba(63, 128, 33, 0.95);
color: black;
}
</style>
<span>Any textual selection in this sentence should have a green background when the window is inactive.</span>
<script>
var span = document.querySelector("span");
window.getSelection().setBaseAndExtent(span, 0, span, 1);
</script>