Source code

Revision control

Copy as Markdown

Other Tools

Test Info:

<!DOCTYPE html>
<meta charset="UTF-8">
<title>CSS Highlight API Test: Non-conflicting attributes</title>
<link rel="match" href="custom-highlight-painting-prioritization-003-ref.html">
<meta name="assert" value="Non-conflicting attributes for highlights will be painted even if lower priority">
<style>
::highlight(highlight-1) {
background-color: blue;
color: white;
}
::highlight(highlight-2) {
background-color: yellow;
}
</style>
<body>
<p>This is an example of two overlapping highlights</p>
</body>
<script>
const text = document.querySelector("p").firstChild;
// Create two overlapping highlights
const range1 = new Range();
range1.setStart(text, 5);
range1.setEnd(text, 10);
const range2 = new Range();
range2.setStart(text, 10);
range2.setEnd(text, 18);
const highlight1 = new Highlight(range1);
const highlight2 = new Highlight(range2);
CSS.highlights.set("highlight-1", highlight1);
CSS.highlights.set("highlight-2", highlight2);
</script>