I'm looking for a solution to display an address on a webpage in two different formats based on the length. The first format should be:
Street Number, PostalCode City
If the address is too long to fit on one line, it should be displayed as:
Street Number
PostalCode City
I've managed to handle the line break, but I'm struggling with removing the comma. Is there a way to achieve this using just CSS or minimal JS?
Here's my current code:
HTML:
<div class="floatLeft">
Street<span> </span>12<span>, </span>
</div>
<div class="floatLeft">9000<span> </span>Gent</div>
CSS:
.floatLeft {
float:left;
}
Check out my working example on JS Fiddle: https://jsfiddle.net/7w70fff1/1/