Suppose that you have something like <div>foo bar</div>
in a web page. This might get rendered as
foo bar
or
foo
bar
depending on whether the element gets word wrapped (which depends on its width and the value of various css properties such as white-space
, word-break
, overflow-wrap
, etc).
Is there a way to determine how has the browser rendered the text in such an element with respect to word wrapping? i.e., I am looking for javascript code that would return something like ["foo", "bar"]
(in the case wrapping did occur).
It seems that getClientRects
returns separate boxes for each line (it appears to be working for inline elements only). But I am looking something that also gives information about the text.