67

How do you increase the height of an textbox? (along with its font size)

Paul Dixon
  • 295,876
  • 54
  • 310
  • 348
mrblah
  • 99,669
  • 140
  • 310
  • 420
  • you shouldn't use explicit pt or px measurements for css, you should always use ems for increased accessibility. – Andrew Bullock Jul 20 '09 at 11:04
  • I'm having the same problem, height does not work :( http://codepen.io/leongaban/pen/Eknsc it's because of search, I'll post a new question tomorrow – Leon Gaban Jun 20 '13 at 04:46

8 Answers8

69

I'm assuming from the way you worded the question that you want to change the size after the page has rendered?

In Javascript, you can manipulate DOM CSS properties, for example:

document.getElementById('textboxid').style.height="200px";
document.getElementById('textboxid').style.fontSize="14pt";

If you simply want to specify the height and font size, use CSS or style attributes, e.g.

//in your CSS file or <style> tag
#textboxid
{
    height:200px;
    font-size:14pt;
}

<!--in your HTML-->
<input id="textboxid" ...>

Or

<input style="height:200px;font-size:14pt;" .....>
Paul Dixon
  • 295,876
  • 54
  • 310
  • 348
37

Note that if you want a multi line text box you have to use a <textarea> instead of an <input type="text">.

Jan Aagaard
  • 10,940
  • 8
  • 45
  • 80
11

Increasing the font size on a text box will usually expand its size automatically.

<input type="text" style="font-size:16pt;">

If you want to set a height that is not proportional to the font size, I would recommend using something like the following. This prevents browsers like IE from rendering the text inside at the top rather than vertically centered.

.form-text{
    padding:15px 0;
}
Sam Becker
  • 19,231
  • 14
  • 60
  • 80
  • 1
    Good point, due to the question I was assuming he wanted to set both, however if it is just to increase the size of the textbox to fit the large text then this would be the ideal solution. – James Jul 20 '09 at 10:55
6
<input type="text" style="font-size:xxpt;height:xxpx">

Just replace "xx" with whatever values you wish.

user
  • 16,429
  • 28
  • 80
  • 97
5
  • With inline style:

    <input type="text" style="font-size: 18pt; height: 40px; width:280px; ">
    
  • or with apart CSS:

    HTML:

    <input type="text" id="txtbox">
    

    CSS:

    #txtbox {
        font-size: 18pt;
        height: 42px;
        width : 300px;
    }
    
Janarthanan Ramu
  • 1,331
  • 16
  • 17
4

If you want multiple lines consider this:

<textarea rows="2"></textarea>

Specify rows as needed.

Gayan Dasanayake
  • 1,933
  • 2
  • 17
  • 22
0

Don't the height and font-size CSS properties work for you ?

Cerebrus
  • 25,615
  • 8
  • 56
  • 70
0

Use CSS:

<html>
<head>
<style>
.Large
{
    font-size: 16pt;
    height: 50px;
}
</style>
<body>
<input type="text" class="Large">
</body>
</html>
James
  • 80,725
  • 18
  • 167
  • 237