JSFiddle - React, Tailwind, and code Playground

by Saravanan Kuppusamy

HTML

<h1>Preserved non-breaking space does not work when font changes</h1>
<h2>non-breaking space (&amp;#x00A1;) used when typeset with Times font</h2>
<div style='font-family:Times;'>
<p>This is some</p>
<p>&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;text I would</p>
<p>like to</p>
<p>&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;&#x00A0;format and it nicely allows for several lines written with automatic lines breaks as well, as we can see here. How can I do this...

CSS

body{margin:50px;}
	p{margin-top:0em;margin-bottom:0em;line-height:1.0;}
	h1{font-size:130%;background:red;color:white;padding:5px;font-family:Tahoma;}
	h2{font-size:100%;margin-top:20px;padding:5px;border-bottom:2px solid orange;border-right:2px solid orange;font-family:Tahoma;}

JavaScript

$(function(){
$("span[data-grid]").each(function(index){
	var myElt=$(this);
	var mostWide=0;
	$("span[data-grid='"+myElt.attr('data-grid')+"']").each(function(index){
	if(mostWide<$(this).offset().left) mostWide=$(this).offset().left;
	});
	$("span[data-grid='"+myElt.attr('data-grid')+"']").each(function(index){
	$(this).css('margin-left',(mostWide-$(this).offset().left)+'px');
	$(this).removeAttr('data-grid');
	});
});
});