Hide html horizontal but not vertical scrollbar

William Jones picture William Jones · Apr 7, 2010 · Viewed 460.2k times · Source

I have an HTML textarea that is of fixed width, but variable height. I would like to set overflow:scroll and be able to show a vertical scrollbar, but not a horizontal one. I am not able to use overflow:auto due to other things specific to my situation.

I know there is no way using CSS2 to show only vertical but not horizontal scrollbars. Is there anything I can do with JavaScript to hide the horizontal scrollbar?

Answer

Nick Craver picture Nick Craver · Apr 7, 2010

You can use css like this:

overflow-y: scroll;
overflow-x: hidden;