Is there a way to automatically justify words using letter spacing, each in its row, to a defined width, using CSS?
For example, "Something like this" would look, well, something like this:
Is there a non-obtrusive way to apply such styling to my text? I believe pure CSS doesn't have this option (at least not with CSS versions before 3, CSS3 seems to have a text-justify
property, but it's not well supported yet), so js solutions would be fine also.
What is wrong with
text-align: justify
? I think I might be misunderstanding your question.I know this is an old topic, but I faced this the other night. And found a suitable solution using tables.
Every letter shall be put into a
<td> </td>
I know it looks tedious, but if you wanna do this, it would be for a word or two, right? Or you always can use JS to fill it if is too much. However, this is only CSS and very versatile solution.Using letter-spacing the letters get distributed properly. You should play around with it, depending on the width of the table.
See the example here
Crossbrowser safe, virtually nothing shall differ. Is just CSS.
I used it in My website which is in english and spanish. the subtitle under my name in spanish has an additional letter and it will step out the width. Using the tables explained above, it gets distributed to the same width automatically. Spacing it manually I'd had to define a whole condition for each language to go around that.
The css only solution is
text-justify: distribute
https://www.w3.org/TR/css-text-3/#text-justify but the support is still very poor.A small experiment using
text-align-last: justify
and adding spaces between letters.