Log in

View Full Version : How To Align Text in Text Box (Top) Vertically



arulllk
01-09-2012, 09:26 AM
Hi Please Help me in this,


I have textfield of height 300px. and text in the textfiled get aligned vertically center automatically, i want it to be top Aligment.

Please give me your suggestions.

coothead
01-09-2012, 09:41 AM
Hi there arulllk,

and a warm welcome to these forums. ;)

Which HTML element are you referring to when you say....

I have textfield of height 300px.

Perhaps you could supply us with the code that you are using, also.

coothead

arulllk
01-09-2012, 10:16 AM
Hi My code
is
<form>
<input align="top" name="" type="text" class="textInput2" />
</form>

and my css is

.textInput2
{
width: 170px;
color: #000000;
margin-top: 0px;
margin-left: 5px;
height:100px;
padding-top:0px;
vertical-align:top;
}

i want text in that text area vertically aligned to top

coothead
01-09-2012, 10:38 AM
Hi there arulllk,

I think that you should use the textarea element for your project...


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="language" content="english">
<meta http-equiv="Content-Style-Type" content="text/css">

<title></title>

<style type="text/css">
#textInput2 {
width:170px;
height:100px;
margin-left:5px;
}
</style>

</head>
<body>

<form action="#">
<div>
<textarea id="textInput2" name="mytextarea"></textarea>
</div>
</form>

</body>
</html>

coothead

arulllk
01-09-2012, 10:55 AM
Hi coothead,

Thank you for spending wonderful time of yours.

Actually i did that only in my project and in ie if we use text area it shows scroller and with the help of css i get rid of it also.

so what i am looking out is is there any way we can align the text in text box vertically top Just to know

Any ways thanks to spend your time for me

coothead
01-09-2012, 11:25 AM
Hi there arulllk,

the input type="text" element is used for a single line of text.

It does not matter what height you apply to this element, the text will always be vertically-aligned in the middle.

coothead

arulllk
01-09-2012, 12:00 PM
Thank You Very much

Now i got it

Thanks Very Much

coothead
01-09-2012, 12:02 PM
No problem, you're very welcome. ;)
coothead