115

Following up to my previous question (Add a scrollbar to a <textarea>) on how to always see the scrollbar in a <textarea>, I am now wondering how you would set it so that there is no scrollbar in the <textarea>, even when the text overflows. To scroll down with this, you would use the arrow keys or the mouse to navigate through the text.

How can I do this?

Community
  • 1
  • 1
user2370460
  • 7,470
  • 10
  • 31
  • 46

9 Answers9

183

Try the following, not sure which will work for all browsers or the browser you are working with, but it would be best to try all:

<textarea style="overflow:auto"></textarea>

Or

<textarea style="overflow:hidden"></textarea>

...As suggested above

You can also try adding this, I never used it before, just saw it posted on a site today:

<textarea style="resize:none"></textarea>

This last option would remove the ability to resize the textarea. You can find more information on the CSS resize property here

Shaggy
  • 6,696
  • 2
  • 25
  • 45
tinthetub
  • 2,120
  • 1
  • 14
  • 22
24

style="overflow: hidden" and style="resize: none" were the ones that did the trick.

Lucas Zamboulis
  • 2,494
  • 5
  • 24
  • 27
Dinder Logic
  • 303
  • 2
  • 2
18

Give a class for eg: scroll to the textarea tag. And in the css add this property -

.scroll::-webkit-scrollbar {
   display: none;
 }
<textarea class='scroll'></textarea>

It worked for without missing the scroll part

shreyasm-dev
  • 2,711
  • 5
  • 16
  • 34
N V R N SATISH
  • 219
  • 3
  • 7
10

For MS IE 10 you'll probably find you need to do the following:

-ms-overflow-style: none

See the following:

https://msdn.microsoft.com/en-us/library/hh771902(v=vs.85).aspx

tintinator
  • 99
  • 1
  • 4
10

Hide scroll bar, but while still being able to scroll using CSS

To hide the scrollbar use -webkit- because it is supported by major browsers (Google Chrome, Safari or newer versions of Opera). There are many other options for the other browsers which are listed below:

    -webkit- (Chrome, Safari, newer versions of Opera):
    .element::-webkit-scrollbar { width: 0 !important }
    -moz- (Firefox):
    .element { overflow: -moz-scrollbars-none; }
    -ms- (Internet Explorer +10):
    .element { -ms-overflow-style: none; }

ref: https://www.geeksforgeeks.org/hide-scroll-bar-but-while-still-being-able-to-scroll-using-css/

FarzadJamshidi
  • 139
  • 1
  • 3
1

Hide scroll bar for Mozilla.

  overflow: -moz-hidden-unscrollable;
MustafaEminn
  • 248
  • 2
  • 6
0

I was able to get rid of my scroll bar on the body of text by removing my max-height attribute of my class.

SauerTrout
  • 471
  • 1
  • 8
  • 13
0

The solutions for just not displaying the scrollbar (instead of completely hiding overflow) mentioned in the other answers (see ::-webkit-scrollbar) work fine except for Firefox. Also the "-moz-" specific solutions mentioned are not working in Firefox for me.

Instead use:

scrollbar-width: none;

for Firefox!

GoldyOnline
  • 519
  • 4
  • 4
0

like some others mentioned, hiding the scrollbars without affecting scrolling I think is the intended behavior: https://blog.logrocket.com/hide-scrollbar-without-impacting-scrolling-css

Patrick
  • 303
  • 1
  • 4
  • 11