Is there a simple way of getting a HTML textarea and an input type=\"text\" to render with (approximately) equal width (in pixels), that works in different browsers?
A C
input[type="text"] { width: 60%; }
input[type="email"] { width: 60%; }
textarea { width: 60%; }
textarea { height: 40%; }
you can also use the following CSS:
.mywidth{
width:100px;
}
textarea{
width:100px;
}
HTML:
<input class="mywidth" >
<textarea></textarea>
These days, if you use bootstrap, simply give your input fields the form-control
class. Something like:
<label for="display-name">Display name</label>
<input type="text" class="form-control" name="displayname" placeholder="">
<label for="about-me">About me</label>
<textarea class="form-control" rows="5" id="about-me" name="aboutMe"></textarea>
You should be able to use
.mywidth {
width: 100px;
}
<input class="mywidth">
<br>
<textarea class="mywidth"></textarea>
As mentioned in Unequal Html textbox and dropdown width with XHTML 1.0 strict it also depends on your doctype. I have noticed that when using XHTML 1.0 strict, the difference in width does indeed appear.
Someone else mentioned this, then deleted it. If you want to style all textareas and text inputs the same way without classes, use the following CSS (does not work in IE6):
input[type=text], textarea { width: 80%; }