I’m trying to activate different stylistic sets, in this example with a button.
My code:
<p id="demo">B</p>
<button type="button" onclick="document.getElementById('demo').style.fontFeatureSettings ='ss01'">Click Me!</button>
I’m trying to activate different stylistic sets, in this example with a button.
My code:
<p id="demo">B</p>
<button type="button" onclick="document.getElementById('demo').style.fontFeatureSettings ='ss01'">Click Me!</button>
3
Answers
You might want to look at this if you haven’t already. It allows you test test your ideas.
Play around with it to get the feel
The issue is, the value
ss01
needs to be"ss01"
… inonclick=
that’s going to get a little messy, though doable like so:(Note: I made it multiline so it’s easy to read here)
I would use
addEventListener
instead for cleaner looking code1)Have you import the font in your head?
2)if you want to change only the style you need to write:
You can also use the line below to activate a specific set of styles:
document.getElementById(‘demo’).style.fontFeatureSettings = "’ss01’";
However, please note that not all browsers support all sets of styles, and you should check in the font documentation if the specific set of styles (such as SS01) is included.