Consider the following html snippet for input tag -
Test Input : <input id="1" name="1" style="width:250px;height:50px;" value="Check alignment" />
Until MS IE 8, by default input
text is top aligned (screenshot below).
Starting MS IE 9 and later, input
text is center aligned (screenshot below).
I have a requirement that all input
be top aligned in MS IE 9 and above (other browsers - chrome, firefox etc aren't much of a concern).
I have tried a few style options (below) but could not get the top alignment as seen in MS IE 8.
- the
align
attribute available forinput
does not seem to work for text. It seems to work for images though. - the
text-align
attribute only aligns text horizontally. No vertical alignment is possible. - the
vertical-align
attribute does not seem to have any affect :(
I checked Crossbrowser input text vertical alignment as suggested by SO, but I still could not get that working as required.
I may be missing something. Any suggestions (read css, html or script in the decreasing order of preference) are welcome :)
As a side-note, it will also be good to know from an UX point of view as to why MS decided to change behavior of input
text after MS IE 8.
[EDIT]: I am dealing with legacy code. I've been advised against changes that can break automated UI testing. So, <textarea>
is not the first choice. Likewise, wrapping in a <div>
or replacing with jquery
based alternative is not being considered.