| <!DOCTYPE html> |
| <html> |
| <head> |
| <meta charset="utf-8"> |
| <title>Multiple custom highlight pseudo elements.</title> |
| <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/#creating-highlights"> |
| <link rel="match" href="highlight-text-expected.html"> |
| <metad name="assert" content="Multiple highlights should be able to be specified."> |
| <style> |
| #out::highlight(example-highlight) { |
| background-color: yellow; |
| color:green; |
| } |
| #scoped::highlight(example-highlight) { |
| background-color: blue; |
| color:red; |
| } |
| </style> |
| </head> |
| <body> |
| <div id="out"><span id="text1">One two three</span></div> |
| <div id="scoped"><span id="text2">four five six</span></div> |
| <span id="text3">seven eight nine</span> |
| |
| <script> |
| let textElement1 = document.getElementById('text1'); |
| let textElement2 = document.getElementById('text2'); |
| let textElement3 = document.getElementById('text3'); |
| let highlightRangeGroup = new HighlightRangeGroup(new StaticRange({startContainer: textElement1, startOffset: 0, endContainer: textElement1, endOffset: 3})); |
| highlightRangeGroup.add(new StaticRange({startContainer: textElement2, startOffset: 5, endContainer: textElement2, endOffset: 9})); |
| |
| CSS.highlights.set("example-highlight", highlightRangeGroup); |
| </script> |
| </body> |
| </html> |