I want to emphasise the last 3 characters of a string, example:
123456789
Easy to wrap the last three with <strong> or <span class="">, but I was wondering if it could be done with CSS only? So the html would be something like:
<span class="mytext">123456789</span>
With the emphasis added in CSS mytext class?

::beforeand::afterPseudo-elements {content: attr()} ValuesDemo 1
::beforeand::afterdata-before="0123456"anddata-after="789"to the elementcontent: attr(data-before)andcontent: attr(data-after)andfont-weight: 900chUnit of Measurement and Monospaced FontsDemo 2
Set the following at the top of the CSS:
All font related properties will reference this ruleset. Not only will this facilitate consistency, it is also very responsive.
1ch= the width of a zero character:"0"from the currentfont-family. If yourfont-familya monospace typeface then all of your characters are exactly the same width.Demo 1
Note: There are two examples: one without text content and two with text content.
Demo 2
Note: This demo is a more complex version of the third example in Demo 1