Boostrap Textarea Height: Control & Resize Form Elements

Ruth Jul 09, 2026

The Bootstrap framework, a popular choice among web developers, offers a wide range of pre-built form controls. Among these, the textarea is a crucial element for user input, especially when longer responses are expected. However, by default, Bootstrap's textarea has a fixed height, which might not always be suitable for all use cases. This article delves into the intricacies of controlling the height of a Bootstrap textarea, ensuring your forms remain functional and visually appealing.

HTML Form Validation with Bootstrap
HTML Form Validation with Bootstrap

Before we dive into the details, let's understand why you might want to adjust the height of a textarea. In many cases, a fixed height might not accommodate all user inputs, leading to scrollbars that can disrupt the user experience. Conversely, an excessively large textarea can consume unnecessary space on the screen. Thus, it's essential to have control over the textarea's height to create an optimal user experience.

Wizard
Wizard

Understanding Bootstrap's Default Textarea Height

By default, Bootstrap sets the height of a textarea to 20px. This height is determined by the `height` property in the `.form-control` class, which is applied to all form controls, including textareas. However, this height is not sufficient for most use cases, as it only accommodates a single line of text.

Bootstrap Forms
Bootstrap Forms

To understand how to adjust the height, it's crucial to grasp how Bootstrap calculates the height of a textarea. The height is determined by the line-height of the font, which is set to 1.5 by default. Therefore, the actual height of the textarea is 1.5 times the font size. For instance, if the font size is 14px, the textarea height will be 21px (14px * 1.5).

Adjusting the Height Using CSS

Bootstrap 5.3 (2025) Cheat Sheet
Bootstrap 5.3 (2025) Cheat Sheet

Bootstrap allows you to adjust the height of a textarea using custom CSS. You can target the `.form-control` class and modify the `height` property. For example, to set the height to 100px, you can use the following CSS:

.form-control {
  height: 100px;
}

However, this approach will affect all form controls, not just textareas. To target only textareas, you can use the `.form-control` class in combination with the `type` attribute:

.form-control[type=textarea] {
  height: 100px;
}

This CSS rule will only apply to textarea elements, allowing you to adjust their height without affecting other form controls.

Free 22+ HTML5 Signup & Registration Forms - HTML, CSS
Free 22+ HTML5 Signup & Registration Forms - HTML, CSS

Using Bootstrap's Input Groups for Dynamic Heights

In some cases, you might want the textarea to expand as the user types. Bootstrap's input groups can be used to achieve this effect. An input group consists of an input (in this case, a textarea) and an add-on. The add-on can be used to trigger an event that adjusts the height of the textarea.

Here's an example of how you can use an input group to create a textarea that expands as the user types:

A Beginner's Guide to the Latest Bootstrap 5 Utilities
A Beginner's Guide to the Latest Bootstrap 5 Utilities

<div class="input-group">
  <textarea class="form-control"></textarea>
  <div class="input-group-append">
    <button class="btn btn-outline-secondary" type="button" id="expandTextarea">Expand</button>
  </div>
</div>

In this example, the `expandTextarea` button can be used to trigger a JavaScript function that adjusts the height of the textarea. Here's an example of how you can implement this functionality using jQuery:

$('#expandTextarea').click(function() {
  var textarea = $('.form-control');
  textarea.css('height', 'auto');
  textarea.css('height', textarea.prop('scrollHeight') + 'px');
});

This JavaScript code sets the height of the textarea to `auto`, allowing it to expand as the user types. It then sets the height to the scroll height of the textarea, ensuring that the textarea expands to accommodate the user's input.

📝 Create Forms in HTML
📝 Create Forms in HTML
some type of text that is being displayed on a computer screen, with different colors and sizes
some type of text that is being displayed on a computer screen, with different colors and sizes
a screenshot of a web page with an image of the user's profile
a screenshot of a web page with an image of the user's profile
Bootstrap Registration Forms: 3 Free Responsive Templates | AZMIND
Bootstrap Registration Forms: 3 Free Responsive Templates | AZMIND
UI 디자인 가이드 : Text fields
UI 디자인 가이드 : Text fields
the login page for wordpress with an arrow pointing up to the account information section
the login page for wordpress with an arrow pointing up to the account information section
HTML form tutorial: How to design HTML Form example
HTML form tutorial: How to design HTML Form example
the back ground menu is shown in black and white, with different font options for each section
the back ground menu is shown in black and white, with different font options for each section
a screenshot of the external ui kit, which includes several options for each user to use
a screenshot of the external ui kit, which includes several options for each user to use
Angular Material Registration Form Template
Angular Material Registration Form Template
Bootstrap 4: What’s New
Bootstrap 4: What’s New
How to break long forms into steps that convert
How to break long forms into steps that convert
How to Group Form Fields: <fieldset> & <legend> 🗂️
How to Group Form Fields: <fieldset> & <legend> 🗂️
the screenshot shows an image of a web page with two different settings, one for each section
the screenshot shows an image of a web page with two different settings, one for each section
13 Must-Follow Rules for Styling Contact Forms (That Actually Convert)
13 Must-Follow Rules for Styling Contact Forms (That Actually Convert)
20 UI/UX Mistakes That Can Ruin Your Mobile App
20 UI/UX Mistakes That Can Ruin Your Mobile App
Registration Form
Registration Form
a form that has been placed on top of a piece of paper
a form that has been placed on top of a piece of paper
UI Designer’s Guide to Creating Forms & Inputs
UI Designer’s Guide to Creating Forms & Inputs
Student Registration Form in HTML with CSS | Completely Free
Student Registration Form in HTML with CSS | Completely Free

Responsive Textarea Heights

In responsive design, it's crucial to ensure that your textareas adapt to different screen sizes. By default, Bootstrap's textareas are not responsive, but you can make them responsive by using media queries to adjust their height based on the screen size.

Here's an example of how you can use media queries to make a textarea responsive:

@media (max-width: 768px) {
  .form-control[type=textarea] {
    height: 50px;
  }
}

@media (min-width: 769px) {
  .form-control[type=textarea] {
    height: 100px;
  }
}

In this example, the textarea will have a height of 50px on screens smaller than 769px and a height of 100px on screens larger than or equal to 769px.

Using Placeholder Text to Simulate Height

In some cases, you might want to use placeholder text to simulate the height of a textarea. This can be useful when you want to provide a hint to the user about the expected length of their input. To achieve this, you can use the `placeholder` attribute in combination with the `rows` attribute:

<textarea class="form-control" placeholder="This is a sample text..." rows="4"></textarea>

The `placeholder` attribute provides the hint text, while the `rows` attribute determines the number of lines in the textarea. In this example, the textarea will have a height that accommodates four lines of text, providing a visual cue to the user about the expected length of their input.

In conclusion, while Bootstrap's default textarea height might not be sufficient for all use cases, the framework provides several tools to adjust the height of a textarea. Whether you're using custom CSS, input groups, media queries, or placeholder text, you can create textareas that are functional, visually appealing, and responsive. By mastering these techniques, you can create forms that provide an optimal user experience, regardless of the device or screen size.