I have a textarea and I want it to be justified so all the lines are equal in width and to be centered to the text stays in the middle of the textarea when it's not at maximum line length.
This is my textarea:
<textarea class="Whiteboard" type="text" placeholder="Type something..."></textarea>
...and the CSS:
textarea.Whiteboard{
resize: none;
background-color: #F1F1F1;
border: none;
height: 500px;
width: 800px;
text-align: center;
font-size: 50px;
}
Thank you all!
Alternative: use
contenteditable
In order to center the textarea element, you have to declare it as a block element in CSS and then add typical centering rules, if necessary.
I was looking for an answer to this and could not find out what I was looking for; hence this post.
Unfortunately there is no concrete CSS solution at the time of writing to achieve the desired result.
However CSS level 3 has introduced a feature under the name
text-align-last
to handle the alignment of the last line of a block:But it is still in Working Draft state. Hence the browser support is not good enough to rely on this technology (It's still buggy on Chrome 35 and only works on Firefox 12+).
Here is an example which I'm not able to verify (because of my FF4. Yes! shame on me):