Justify Text In A Html/xhtml Textarea
Solution 1:
I dealt with same issue and found out very stupid solution. Make sure that the text to be displayed falls within the start and end tag elements in the same line and not in the next line
<textarea name="description"readonly="readonly" rows="4" cols="66">Text aligned toward left</textarea>
and not like
<textarea name="description"readonly="readonly" rows="4" cols="66">
Text aligned toward left
</textarea>
Solution 2:
Depending on your target browser... this solution works in Chrome. It does not work work in Firefox however... but I'll post it anyway.
In addition to setting text-align: justify, you must also set white-space: normal.
textarea {
text-align: justify;
white-space: normal;
}
JSFIDDLE: http://jsfiddle.net/cb5JN/
Solution 3:
I believe that common practice is to use the TEXTAREA
for input without worying about justification; and then, once the input is processed (i.e. the FORM
is submitted, or an event of the TEXTAREA
is captured), the contents are displayed in a non-editable text element (such as P
, SPAN
, TD
) where the text-align: justify;
style attribute will be honored.
Solution 4:
For me (in Firefox), this code works perfectly:
textarea{
resize: none;
text-align: justify;
white-space: pre-line;
-moz-text-align-last: left;
text-align-last: left;
}
Solution 5:
Using a common div with contenteditable="true" worked in my case. Doesn't work for most mobile browsers though.
<divcontenteditable="true">Some content</div>
Post a Comment for "Justify Text In A Html/xhtml Textarea"