Your question mentioned wanting to style integer values in HTML by using CSS off of a single class. Although there's a working answer with JS, this can be accomplished with only CSS.
There is a unicode-range
value which can be added to @font-face
rules to only apply the font to certain characters. It is supported in all modern browsers and IE back to version 9 (https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/unicode-range).
You can use it to apply different fonts with different weights inherent to the font to the digits only. Consider the following, which applies Arial Black to '0-9' and '.' characters:
@font-face {
font-family: boldDigits;
src: local('Arial');
}
@font-face {
font-family: boldDigits;
src: local('Arial Black');
unicode-range: U+0030-0039, U+002E;
}
body {
font-family: boldDigits;
}
Example live at: http://codepen.io/honzie/pen/ZOPKvr.
Note that there are a couple downsides to this: you can't apply different font-weight
properties directly here. So, if you want a font that's not Arial, you may have to either use a Google Font or a custom-designed font.