Fri, 16 Jan 2015 18:13:44 +0100
Integrate suggestion from review to improve consistency with existing code.
1 <!--
2 Any copyright is dedicated to the Public Domain.
3 http://creativecommons.org/publicdomain/zero/1.0/
4 -->
5 <!DOCTYPE html>
6 <style>
7 html, body { margin: 0 }
8 svg, div { display: inline-block; width: 700px; height: 200px }
9 div { font: 16px sans-serif; text-decoration: underline; margin-left: -700px; vertical-align: 100px }
10 span { margin-left: 100px; }
11 </style>
12 <body>
13 <svg></svg><div><span>hello</span></div>
14 <script>
15 var span = document.getElementsByTagName("span")[0];
16 var range = document.createRange();
17 range.setStart(span.firstChild, 1);
18 range.setEnd(span.firstChild, 4);
19 window.getSelection().addRange(range);
20 </script>
21 </body>