Skip to content

Truly independent web browser

467 B
Raw Blame
<!DOCTYPE html>
<style>
p {
    font: 20px sans-serif;
    line-height: 1.5;
}
::selection {
    color: black;
    background: yellow;
}
</style>
<p>Before Highlighted passage after</p>
<script>
const text = document.querySelector("p").firstChild;
const start = text.textContent.indexOf("Highlighted passage");
const range = new Range();
range.setStart(text, start);
range.setEnd(text, start + "Highlighted passage".length);
getSelection().addRange(range);
</script>