How do browsers decide where selected text is?

时间:2015-05-24 20:21:33

标签: html browser html-rendering

How do web browsers decide which part of the screen to show as "highlighted" when you select a bit of text? It always seems a bit unpredictable and buggy. For example, on this website, if I select a paragraph, it looks like this:

enter image description here

The highlighted section clearly goes out of bounds of its parent element and leaks out onto the links on the right. Why is that how the browser chooses to highlight the text? I know for sure that the browser (Chrome, in this case) is aware of where the element containing that text actually is, which can clearly be seen from the development tools:

enter image description here

Why, then, are we presented with the wrong "highlight"? How does this work under the hood?

0 个答案:

没有答案