You can see that there are four declarations of fonts. One's regular, one's bold, one's italic, and one's bold/italic. However, they all have the same value for font-family: "Adobe Clean".
I was under the impression that that needs to be a unique name, cause now when any element is given font-family: "Adobe Clean", there are four font styles to choose from (I assume that the last one will be used).
So my question is, am I correct? Or is the code above actually fine? Reason I'm asking is because someone else (not a newbie, quite an expert) claims it's correct so I'm seriously doubting my own understanding of this.
Indeed, it turns out that's exactly what it does. All four font styles (regular, italics, bold, and bold italics) have the same name, but when the text in the markup is wrapped in <strong> tags, it will take the second one. When the text in the markup is wrapped in <em>, it will take the third one. And then when both tags are used, it will take the fourth one.
I believe that is correct, it can be used with four different declarations for different styles. See here: https://developer.mozilla.org/en-US/docs/CSS/@font-face (note that the support tabel is waaay out-of-date on that page).
I've been doing this quite a while with Font-Faces and it works fine.
What you're effectively doing is providing multiple versions of the font but with different weight/style parameters.
For example, if p/h tags are set to use this font, then you choose, font-style: italic; it will select the version that has "italic" font-style. Similarly for font-weight. You don't need to explicitly select one, rather it chooses the one that matches for you.
I've not had a problem using this previously.
You can see it on my site here with Lato as the font --> Main Site and Stylesheet
Hey everyone. I recently came across this piece of code, I believe it's wrong -- but I want to make sure I understand it correctly. Here it goes:
You can see that there are four declarations of fonts. One's regular, one's bold, one's italic, and one's bold/italic. However, they all have the same value for font-family: "Adobe Clean".
I was under the impression that that needs to be a unique name, cause now when any element is given
font-family: "Adobe Clean", there are four font styles to choose from (I assume that the last one will be used).So my question is, am I correct? Or is the code above actually fine? Reason I'm asking is because someone else (not a newbie, quite an expert) claims it's correct so I'm seriously doubting my own understanding of this.
Interesting. I've always declared them separately, but this looks like it makes much more sense if it actually works. Isn't that easy to test?
You know, I tried testing it, and I'm getting really unpredictable results. I'll set up a test case so I can show what the issue is.
@TheDoc: how COULD it work? How would you call, for example, the third "Adobe Clean" one?
rename the eot files?? Like Adobe Clean 1 and 2 and so on?
The filenames are already unique, that's not the problem.
In a perfect world, the browser would be smart enough to look for the font-face declared as
font-style: italicwhen using<em />.Indeed, it turns out that's exactly what it does. All four font styles (regular, italics, bold, and bold italics) have the same name, but when the text in the markup is wrapped in
<strong>tags, it will take the second one. When the text in the markup is wrapped in<em>, it will take the third one. And then when both tags are used, it will take the fourth one.Right....? :)
That's awesome!
Quick side note: instead of wrapping stuff in
<code>you can just wrap it in a backtick `. This will enable you to show off code inline.You should also do a test case in CSS.
Example
I believe that is correct, it can be used with four different declarations for different styles. See here: https://developer.mozilla.org/en-US/docs/CSS/@font-face (note that the support tabel is waaay out-of-date on that page).
This looks like a good candidate for a mixin then!
I've been doing this quite a while with Font-Faces and it works fine.
What you're effectively doing is providing multiple versions of the font but with different weight/style parameters.
For example, if p/h tags are set to use this font, then you choose, font-style: italic; it will select the version that has "italic" font-style. Similarly for font-weight. You don't need to explicitly select one, rather it chooses the one that matches for you.
I've not had a problem using this previously.
You can see it on my site here with Lato as the font --> Main Site and Stylesheet