css - Font Face Selectors with weight and style properties - browser ignores all but last selector -
i using multiple web fonts of same family avoid browsers rendering in faux-bold , faux-italics. when declaring selectors, set same name all"font-family" properties , using "font-weight" , "font-style" differentiate.
here's example i'm using exo.
@font-face { font-family: "exo"; src: url("../fonts/exo/exo-regular.eot"); src: url("../fonts/exo/exo-regular.eot?#iefix") format("embedded-opentype"), url("../fonts/exo/exo-regular.woff2") format("woff2"), url("../fonts/exo/exo-regular.woff") format("woff"), url("../fonts/exo/exo-regular.ttf") format("truetype"), url("../fonts/exo/exo-regular.svg#exo") format("svg"); font-weight: "normal"; font-style: "normal"; } @font-face { font-family: "exo"; src: url("../fonts/exo/exo-bold.eot"); src: url("../fonts/exo/exo-bold.eot?#iefix") format("embedded-opentype"), url("../fonts/exo/exo-bold.woff2") format("woff2"), url("../fonts/exo/exo-bold.woff") format("woff"), url("../fonts/exo/exo-bold.ttf") format("truetype"), url("../fonts/exo/exo-bold.svg#exo") format("svg"); font-weight: "bold"; font-style: "normal"; } p { font-family: "exo", sans-serif; }
(note: have confirmed paragraph tag not inheriting font-weight selector).
from above css expecting <p/>
tag have normal font weight. instead, instances of <p/>
bold. when checking browser inspector, font-weight, reads 'normal.'
i using roboto web fonts things normal, bold, italics, , bold-italics. whatever last @font-face selector listed gets used default.
i've seen different ways implement approach using different font-family names (e.g. font-family: "exo-bold"), shouldn't have that. objective to:
- use multiple web font files represent font in different states (e.g. exo-regular.woff, exo-bold.woff).
- use same font-family name weight , style variants of same font.
- include font-weight , font-style properties identify variants.
- set weight , style using other css or markup
<strong>
.
it seems i've done before , it's worked. can spot error in approach? appreciated!!!
no quotes should used in font-weight
, font-style
rules. work:
@font-face { font-family: "exo"; /* files normal weight */ font-weight: normal; font-style: normal; } @font-face { font-family: "exo"; /* files bold weight */ font-weight: bold; font-style: normal; }
actually, in css need quotes when have spaces or other reserved characters in font names or file names. should work:
<!-- language: lang-css --> @font-face { font-family: exo; src: url(../fonts/exo/exo-regular.eot); src: url(../fonts/exo/exo-regular.eot?#iefix) format(embedded-opentype), url(../fonts/exo/exo-regular.woff2) format(woff2), url(../fonts/exo/exo-regular.woff) format(woff), url(../fonts/exo/exo-regular.ttf) format(truetype), url(../fonts/exo/exo-regular.svg#exo) format(svg); font-weight: normal; font-style: normal; } @font-face { font-family: exo; src: url(../fonts/exo/exo-bold.eot); src: url(../fonts/exo/exo-bold.eot?#iefix) format(embedded-opentype), url(../fonts/exo/exo-bold.woff2) format(woff2), url(../fonts/exo/exo-bold.woff) format(woff), url(../fonts/exo/exo-bold.ttf) format(truetype), url(../fonts/exo/exo-bold.svg#exo) format(svg); font-weight: bold; font-style: normal; } p { font-family: exo, sans-serif; }
i use quotes in css when doesn't work without.
but never quote normal css terms, they'll stop working.
Comments
Post a Comment