14-day Cloud trial
Start today. For free.

One editor. 50+ features. Zero constraints. After your trial, retain the advanced features.

Try Professional Plan for FREE
PricingContact Us
Log InGet Started Free

How to disable textarea scrollbars with TinyMCE

May 11th, 2023

5 min read

A vertical scrollbar separated from the editor

Written by

Joe Robinson

Category

How-to Use TinyMCE

When you’re building your own app, you have complete control over the interface and you can change how it looks to improve the experience for your users. That’s why it’s so deeply annoying when you add a third party component to your app, and the appearance can’t be changed. Worse still, that unchangeability also spells trouble as far as support tickets and complaints.. 

Then there’s usually a laundry list of complaints to take on, like: “How can I disable the toolbar? How can I disable the textarea scrollbar? How can I change the background color?” It’s honestly not a great use of your time to chase down solutions when you have competing priorities. 

The easy answer is to dispense with it all by selecting components that empower customers rather than bewilder them, especially when it comes to their text editor (like disabling the textarea scrollbar for example).

Choosing the TinyMCE WYSIWYG as your app’s rich text editor empowers your customers by providing a host of reliable features, and unblocks you by giving control over how the editor looks. For instance, this article explains how to disable textarea scrollbars if you need to. It’s just a matter of controlling the CSS that styles the TinyMCE editor!

How to disable the textarea scrollbar in TinyMCE

To disable the textarea scrollbar, take a close look at your TinyMCE init script, which configures and controls how TinyMCE works. If you haven’t added it already, add the content_style option to the list of values that makes up the list. Add the following CSS properties to the content_style value: 

content_style: `html body { overflow: hidden; }`;

Adding this option to your TinyMCE init script prevents the editor from making scrollbars. But this only works if you have access to the content inside the iframe element. With the content_style option, you do have access to how TinyMCE appears.

How to add a textarea scrollbar

TinyMCE has a vertical scrollbar enabled by default. It appears when the editor content is larger than the editor size. If you only want to temporarily disable the textarea scrollbar, you can switch off this bit of CSS by commenting it out. 

This then restores the default TinyMCE text editor view, which includes a vertical scrollbar. You could also configure a dynamic option to enable or disable the scrollbar with a custom toolbar option, or menu option.

Disabling the textarea scrollbar within a TinyMCE Demo

The procedure in the following sections shows the steps you need to change or disable textarea scrollbars. 

Setting up the demo for disabling scrolling

First, you need an API key. This key gives you free access to TinyMCE Premium plugins for 14 days. Navigate to the Get-tiny sign up page to get your FREE API key. 

  1. Create an index.html file, and add the following HTML:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TinyMCE Demo</title>
</head>
    <body>
    </body>
</html>
  1. With your file open, in the head section, add script tags, and reference TinyMCE Cloud through a CDN link within the script tags. This is what the link looks like:

<script
  src="https://cdn.tiny.cloud/1/your-api-key/tinymce/6/tinymce.min.js"
  referrerpolicy="origin"
></script>;

Note: For the Tiny Cloud connection, creating an account with TinyMCE gets you a FREE API key. When you use this key, you get access to Premium TinyMCE plugins for 14 days, as well as no warning messages concerning API keys in the text area.

  1. Add another pair of script tags, add the following JavaScript. It’s the tinymce.init method, and it’s how you control TinyMCE:

<script>
   tinymce.init({
   selector: '#editor',
   plugins: 'powerpaste casechange searchreplace autolink directionality advcode visualblocks visualchars image link media mediaembed codesample table charmap pagebreak nonbreaking anchor tableofcontents insertdatetime advlist lists checklist wordcount tinymcespellchecker editimage help formatpainter permanentpen charmap linkchecker emoticons advtable export autosave',
   toolbar: 'undo redo print spellcheckdialog formatpainter | blocks fontfamily fontsize | bold italic underline forecolor backcolor | link image | alignleft aligncenter alignright alignjustify lineheight | checklist bullist numlist indent outdent | removeformat',
   height: '700px'
       });
</script>
  1. Add initial HTML content, and the CSS selector class to some textarea tags. The selector is set as an id with the value “editor” in the TinyMCE init script:

<form id="post">
     <textarea id="editor">Hello, World!</textarea>
    
</form>;
  1. Test run the index.html file by opening it in your browser, or use a local server command with Python or with the PHP command:

The essential tinymce editor working classic mode

Customizing the demo

Here’s how to configure the content_style option to disable the textarea scrollbar in TinyMCE.

  1. Add some additional content around the textarea to give some context as to how disabling the scrollbar looks in something closer to production. This content is drawn from the TinyMCE DMS demo:

<h1 style="text-align: center;">What's your Document Management editing project?</h1>
        <p style="text-align: center;">Are you:</p>
        <div class="container0">
            <p style="text-align: center;"><span style="font-size: 36pt;">📝</span>Building a next-generation document creation solution</strong> and want to offer the best rich text editing experience to your content creators?</p>
            <p style="text-align: center;"><span style="font-size: 36pt;">🗂️</span>Developing an innovative documentation system to organize, track, store, and share documents, and you want to add editing capabilities?</p>
        <div id="container">
          <textarea id="editor">Hello, World!
          </textarea>
        </div>
        <footer></footer>
  1. Add some HTML content to the TinyMCE editor. This content is drawn from the CSS alignment guide at W3Schools:

          <textarea id="editor">
            <h2>Center Align Elements</h2>
            <p>To horizontally center a block element (like div), use margin: auto; Setting the width of the element will prevent it from stretching out to the edges of its container.
                The element will then take up the specified width, and the remaining space will be split equally between the two margins:
                This div element is centered.</p>
            <h3>Example</h3>
              <code style="white-space: pre-wrap;">.center {
            margin: auto;
            width: 50%;
            border: 3px solid green;
            padding: 10px;
        }</code>
            <p><a href="https://www.w3schools.com/css/tryit.asp?filename=trycss_align_container">Try it Yourself »</a></p>
            <b>Note:</b> Center aligning has no effect if the width property is not set (or set to 100%).
          </textarea>
  1. Adjust the height and width of the editor in the TinyMCE init script. The goal is to make a scrollbar appear by default by setting the editor contents to be longer than the editor height:

tinymce.init({
           selector: '#editor',
           ...//skipped content for brevity
          height: '400px',
          width: '700px',
  1. Save the change, and you can see how the TinyMCE editor automatically introduces a scrollbar when the editor content exceeds the editor height:

The basic tinymce DMS demo for textarea scrollbars working

Styling the demo

To move the content closer to something that resembles a real-world application, the next step is to add some CSS to change demo appearance:

  1. Create a style.css file in the same directory as your index.html file

touch style.css
  1. Open the file in your text editor, and add the following CSS to style the demo:

body {
    font-family: Arial, sans-serif;
    background-color:  #33b5e5;
    color: #333;
  }

#container {
    margin: auto;
    height: 800px;
    width: 700px;
    padding: 5px;
    border: 1px solid grey;
    background-color: #fff;
}

footer {
    margin: 10px;
    padding: 5px;
    background-color: #333;
}
  1. Link the stylesheet to your index.html file:

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TinyMCE Demo</title>
    <link rel="stylesheet" href="style.css">
  1. Save the changes, and test the styled demo:

The TinyMCE DMS demo with a design added

Disabling the textarea scrollbar

  1. Add the style_css option to the TinyMCE init script

tinymce.init({
        selector: '#editor',
        plugins: 'powerpaste casechange searchreplace autolink directionality advcode visualblocks visualchars image link media mediaembed codesample table charmap pagebreak nonbreaking anchor tableofcontents insertdatetime advlist lists checklist wordcount tinymcespellchecker editimage help formatpainter permanentpen charmap linkchecker emoticons advtable export autosave',
        toolbar: 'undo redo print spellcheckdialog formatpainter | blocks fontfamily fontsize | bold italic underline forecolor backcolor | link image | alignleft aligncenter alignright alignjustify lineheight | checklist bullist numlist indent outdent | removeformat',
        height: '400px',
        width: '700px',
        content_style:
  1. Set the CSS content:

content_style: `html, body { overflow: hidden; }`,
  1. Save the changes, and test out the textarea without the scrollbar. TinyMCE loads without the textarea scrollbar. To navigate the content, arrow keys are needed, or resizing the editor to see all the contents:

Textarea scrollbar disabled with TinyMCE

Troubleshooting TinyMCE scrollbar problems

If you find that the toolbar has a scrollbar that you don’t want, and you’re adamant about having no scrollbars in the editor at all, check on how your toolbar is configured. If you have the “scrolling” option set for the toolbar_mode configuration, this option is what’s causing your toolbar to have a scrollbar. Change it to “wrap” to remove this scrollbar:

toolbar_mode: "scrolling"; //change to 'wrap'

Another troubleshooting point to check on is where the CSS is placed. If you try adding CSS to remove the textarea scrollbar on the style sheet for the page, it won’t affect the TinyMCE textarea. The CSS stylesheet for the page doesn’t directly affect the TinyMCE editor content, generally. Make sure you use the content_style option.

Also, be aware that setting the option scrolling=no on an iframe or textarea tag doesn’t work in HTML 5, and has issues with the Firefox browser. Setting this option on the textarea tag that contains TinyMCE (when TinyMCE is in classic mode) won’t disable the scrollbar. 

After disabling textarea scrollbars in TinyMCE 

If you need to customize other design points of the TinyMCE editor interface beyond disabling textarea scrollbars, check on the following articles:

And, if you’re building a landing page, there are important elements to look into as well. If you’d like to ask a question about TinyMCE, and you need an effortless text editor solution, you can contact us for information.

TinyMCEDesignProduct Development
byJoe Robinson

Technical and creative writer, editor, and a TinyMCE advocate. An enthusiast for teamwork, open source software projects, and baking. Can often be found puzzling over obscure history, cryptic words, and lucid writing.

Related Articles

  • How-to Use TinyMCEApr 16th, 2024

    How to enable a Bootstrap WYSIWYG editor: a step-by-step guide

Join 100,000+ developers who get regular tips & updates from the Tiny team.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Tiny logo

Stay Connected

SOC2 compliance badge

Products

TinyMCEDriveMoxieManager
© Copyright 2024 Tiny Technologies Inc.

TinyMCE® and Tiny® are registered trademarks of Tiny Technologies, Inc.