0

I have been looking at https://www.w3schools.com/cssref/css3_pr_text-justify.asp for some time. The problem with text-justify is that it's currently not supported by almost any browser. Is there any polyfill or compatibility shim of some sort that I could use in order to justify my texts with inter-word?

enter image description here

alexandernst
  • 14,352
  • 22
  • 97
  • 197
  • Just to be sure, what the difference you want with [text-align: justify](https://www.w3schools.com/cssref/pr_text_text-align.asp) ? – Arthur Mar 08 '19 at 15:46
  • Asking for a polyfill (i.e. a third party resource) is off-topic on SO. But that aside, it is probably very expensive to implement yourself in JS, because that means you have to keep checking possible events that can cause text to reflow, such as window resize, DOM mutations, CSS changes, etc, some of which are not possible to detect. – Terry Mar 08 '19 at 16:00
  • @Arthur text-align is completely different. That is used to align horizontally the text. text-justify, on the other hand, is used to "expand" the letters or words in such a way that the left and the right side of the text are vertically aligned (look at the image in my question). – alexandernst Mar 08 '19 at 16:21
  • @Terry I could re-phrase the question to "How can I achieve the same effect as `text-justify: inter-word` in browsers that don't support that property natively?". – alexandernst Mar 08 '19 at 16:21
  • Thank for the info. @Terry, instead of add a listener on every events, why not setup a single interval and check that container size isn't updated ? (and maybe one/two others check) – Arthur Mar 08 '19 at 16:24
  • @Arthur That's still going to be absurdly expensive. I don't see why you need to run a polling function in the background to constantly readjust the spacing of individual characters. That's an absolute overkill. Also, text reflow can be triggered without changing the size of the container. What if you have a floating element inside the element that changes dimensions? What if you modify the text node of the element? – Terry Mar 08 '19 at 16:26
  • @alexandernst I think yes, according to [Guideline](https://stackoverflow.com/help/how-to-ask) You should ask a question like `you're talking to a busy colleague ` – Arthur Mar 08 '19 at 16:26

0 Answers0