title: HTML - How to get selection offsets with relatives to HTML tags
body: <p>Suppose my HTML looks something like this</p>
  
  <pre><code>&lt;div&gt;
      &lt;p&gt; start&lt;span&gt;span&lt;/span&gt;end &lt;/p&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I need to be be able to get the offsets when a selection is made, without ignoring the span tags.</p>
  
  <p>e.g.
  suppose to user selected </p>
  
  <pre><code>t&lt;span&gt;span&lt;/span&gt;e
  </code></pre>
  
  <p>I want the to get 4 as starting offset and 24 as the ending offset.
  The selection object obtained via window.getSelection() returns 1,8, which is rather useless to me.
  I obviously need to handle all cases where the user selects only the inner span, or part of the span etc.</p>
  
  <p>Thanks</p>