Can I use JavaScript to check (irrespective of scrollbars) if an HTML element has overflowed its content? For example, a long div with small, fixed size, the overflow proper
Another way is compare the element width with its parent's width:
function checkOverflow(elem) { const elemWidth = elem.getBoundingClientRect().width const parentWidth = elem.parentElement.getBoundingClientRect().width return elemWidth > parentWidth }