Is there a CSS property to detect selection overflow?

When you select text in textarea, a visible overlay of the selection is contained in textarea, for example:

Selection contained in element

When you select text on "regular" elements as simple div, you get the following:

Overflowing selection

A visible selection overflows the element. Is there a CSS property or any other way to keep the visible element visible in the HTML element?

+4
source share
1 answer

You can add

overflow:hidden;

in the div.

Demo .

+3
source

All Articles