0

Is there any way in CSS to detect if a textarea has a scrollbar (vertical or otherwise) ?

textarea:has(:scrollbar-shown)

I am checking for latest modern browser versions only.

anjanesh
  • 3,771
  • 7
  • 44
  • 58
  • you can check this https://stackoverflow.com/questions/3238515/javascript-detect-scrollbar-in-textarea – arsyaadi Jul 12 '22 at 03:53
  • But I am not looking for a JavaScript solution - even if its an upcoming CSS4 feature also helps - atleast I'll know that it's in the works. Or will this never happen ? – anjanesh Jul 12 '22 at 03:57

1 Answers1

0

You can use the JavaScript to do that,

    const textArea = document.querySelector("textarea");
    if (textArea.clientHeight < textArea.scrollHeight){
        console.log("The element has a vertical scrollbar!")}

    else {
        console.log("The element doesn't have a vertical scrollbar.")}