3

I have an input with height: 250px as you can see in it's text is in center. Is there any way to place align it to top left corner?

#messageBox
{
    width: 200px;
	height: 250px;
}
<input id="messageBox">

5
  • 5
    This is one gigantic input hehe. Use textarea for this ^^ Commented Sep 29, 2014 at 11:27
  • 1
    Use textarea instead of simple input... !!! Commented Sep 29, 2014 at 11:28
  • Lol where is the type attr of you input? this is not a valid markup Commented Sep 29, 2014 at 11:33
  • stackoverflow.com/questions/326650/… Commented Sep 29, 2014 at 11:37
  • 3
    @Tambo: yes, it's valid; if type is not supplied, or not recognised by the browser, then it defaults to type"=text". See: <input />. Commented Sep 29, 2014 at 11:57

9 Answers 9

11

Use a <textarea> instead:

#messageBox{
    width: 200px;
    height: 250px;
}
<textarea id="messageBox"></textarea>

Sign up to request clarification or add additional context in comments.

Comments

6

Or if you need input and you don't need more rows, you can use padding instead height.

For example this code, but it's look crazy:

#messageBox {
  width: 200px;
  padding: 0 0 250px 0;
}
<input id="messageBox" value="test">

1 Comment

+1, this answer does the job and does not change the premise of the question :)
4

Add bottom padding with box-sizing (so that the padding doesn't increase the height of the input):

#messageBox
{
  width: 200px;
  height: 250px;
  padding-bottom: 222px;
  box-sizing: border-box;
}
<input id="messageBox" />

Comments

1

Maybe add padding and let the height auto compute.

I assume that you know about textarea.

However, if you want the single line input field to have a tall box for design purposes, it can be done.

Design Note: This styling allows you to place a background image below the text input area without having to add extra mark-up, which may be useful at times.

#messageBox
{
  width: 200px;
  padding-bottom: 250px; /* approximately... */
  background:  0 30px no-repeat url(http://placekitten.com/1000/500);
}
<input id="messageBox" value="Test">

Comments

0

Change the HTML as,

<textarea id="messageBox"></textarea>

Use textarea instead of invalid input

Comments

0

html

<textarea id="messageBox"></textarea>

css

#messageBox
{
width: 200px;
height: 250px;
resize:none
}

http://jsfiddle.net/16sb2rnb/3/

Comments

0

You should use the textarea element instead.

<textarea id="messageBox"></textarea>

http://jsfiddle.net/16sb2rnb/5/

Comments

0

You can use the <textarea> element to achieve this.

1 Comment

I think it would be more helpful for the op and further visitors, when you add some explaination to your intension (here: why is textarea a good alternavie way? Maybe with a smal exaple).
0

As the comments say, change <input> to <textarea>

#messageBox {
  resize: none;
}
<textarea id="messageBox" rows="6" cols="50">

To increase height, just add more to rows

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.