Auto space text every 4 characters with CSS?

I wanted to ask if this text can automatically change to this shape when entered with CSS.

Before : 513031421694 // After : 5130 3142 1694


I've tried these (letter spacing / word spacing) with no success and I can only touch CSS.

+3


source to share


1 answer


Unfortunately, for now, a JS solution is probably your only interface to achieve formatting across all element types.

To the CSS Working Group> / a>, which would have addressed this issue, although since 2008 it doesn't seem to have had any movement or mention.

They proposed 2 new CSS rules @decimal-format

and number-format

.

@decimal-format price {
  grouping-separator: ",";
  decimal-separator : "."
}

.price {
  number-format: "###,##0.00", "price";
  /* price is actually redundant as this format would be the default */
}

      



Then a simple class will apply the formatting.

<span class="price">987654321</span>

      

Will display as 987,654,321.00 USD

But this is just an idea that hasn't moved since 2008.

+2


source







All Articles