Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3211548
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T14:44:42+00:00 2026-05-17T14:44:42+00:00

How can I prevent the textarea from stretching beyond its parent DIV element? I

  • 0

How can I prevent the textarea from stretching beyond its parent DIV element?

I have this textarea inside a table which is inside a DIV and it seems that it causes the entire table to stretch out of its bounds.

You can see an example of the same situation even in a more simple case, just putting a text area inside a div (like what is used here in http://www.stackoverflow.com)

You can see from the images below that the textarea can stretch beyond the size of its parent? How do I prevent this?

I’m kind of new to CSS so I don’t really know what CSS attributes should I be using. I tried several like display, and overflow.
But they don’t seem to do the trick.
Anything else I might have missed?

the div section

the text area

UPDATE:
HTML

CSS

textarea {
    max-width: 50%;
}
#container {
    width: 80%;
    border: 1px solid red;
}    
#cont2{
    width: 60%;
    border: 1px solid blue;
} ​

If you put this code inside the http://jsfiddle.net,
you will see that they act differently. Although the textarea is limited to the percentage declared in its css style, it is still possible to get it to cause its parent table to be as large as it wants to be, and then you can see that it spills over its parent border.
Any thoughts on how to fix this?
​

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T14:44:43+00:00Added an answer on May 17, 2026 at 2:44 pm

    To disable resizing completely:

    textarea {
        resize: none;
    }
    

    To allow only vertical resizing:

    textarea {
        resize: vertical;
    }
    

    To allow only horizontal resizing:

    textarea {
        resize: horizontal;
    }
    

    Or you can limit size:

    textarea {
        max-width: 100px; 
        max-height: 100px;
    }
    

    To limit size to parents width and/or height:

    textarea {
        max-width: 100%; 
        max-height: 100%;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I prevent IntelliJ from wrapping JSP code like this? <textarea class=doh><%=foo%></textarea> After
Does a List have a property or mechanism by which I can prevent duplicate
I have a text area which I need to prevent from having javascript entered.
Does anyone know how I can prevent the text in a table cell from
Hi I want to write an application that can prevent other application from using
How can I prevent an application from rendering the viewscript with any parameters. So
How can I prevent Google and other search engines from indexing my website?
How can I prevent my bitmap from being scaled automatically in an ImageView or
How can I prevent a user from tabbing into a field (comboxbox)?
How can I prevent multiple users from being logged in at the same time

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.