custom-highlight-font-metrics-002.html (1323B)
1 <!DOCTYPE html> 2 <meta charset="UTF-8"> 3 <title>CSS Highlight API Test: </title> 4 <link rel="help" href="https://drafts.csswg.org/css-highlight-api-1/"> 5 <link rel="help" href="https://drafts.csswg.org/css-pseudo/#highlight-styling"> 6 <link rel="match" href="custom-highlight-font-metrics-002-ref.html"> 7 <meta name="assert" value="fonts relative units take the correct values, with correct cascade"> 8 <meta name="fuzzy" content="0-128;0-8"> 9 <head> 10 <style> 11 :root { 12 font-size: 16px; 13 } 14 div { 15 margin: 40px; 16 font-size: 20px; 17 } 18 ::highlight(highlight1) { 19 text-underline-offset: 0.5em; 20 text-decoration-line: underline; 21 text-decoration-color: green; 22 text-decoration-thickness: 0.25rem; 23 } 24 #h2::highlight(highlight1) { 25 text-underline-offset: 1.0em; 26 text-decoration-line: underline; 27 text-decoration-color: blue; 28 text-decoration-thickness: 0.125rem; 29 } 30 </style> 31 </head> 32 <body> 33 <div id="h1">A green 10px offset underline 4px thick</div> 34 <div id="h2">A blue 20px offset underline 2px thick</div> 35 <script> 36 let r1 = new Range(); 37 r1.setStart(h1, 0); 38 r1.setEnd(h1, 1); 39 let r2 = new Range(); 40 r2.setStart(h2, 0); 41 r2.setEnd(h2, 1); 42 CSS.highlights.set("highlight1", new Highlight(r1, r2)); 43 </script> 44 </body> 45 </html>