Answer the question
In order to leave comments, you need to log in
Setting fonts in CSS: each style by name or weight property?
Good evening gentlemen! Tell me at the moment the relevance of connecting fonts in this way:
(example with Open Sans, this is just an example, since the necessary web fonts may not be in Google or other services)
@font-face {
font-family: "OpenSansRegular";
src: url("../fonts/OpenSans/OpenSansRegular/OpenSansRegular.eot");
src: url("../fonts/OpenSans/OpenSansRegular/OpenSansRegular.eot?#iefix")format("embedded-opentype"),
url("../fonts/OpenSans/OpenSansRegular/OpenSansRegular.woff") format("woff"),
url("../fonts/OpenSans/OpenSansRegular/OpenSansRegular.ttf") format("truetype");
font-style: normal;
font-weight: normal;
}
@font-face {
font-family: "OpenSansLight";
src: url("../fonts/OpenSans/OpenSansLight/OpenSansLight.eot");
src: url("../fonts/OpenSans/OpenSansLight/OpenSansLight.eot?#iefix")format("embedded-opentype"),
url("../fonts/OpenSans/OpenSansLight/OpenSansLight.woff") format("woff"),
url("../fonts/OpenSans/OpenSansLight/OpenSansLight.ttf") format("truetype");
font-style: normal;
font-weight: normal;
}
Answer the question
In order to leave comments, you need to log in
Correct like this:
@font-face {
font-family: 'OpenSans';
src: url("../fonts/OpenSans/OpenSansRegular/OpenSansRegular.eot");
...
font-weight: 400;
font-style: normal;
}
@font-face {
font-family: 'OpenSans';
src: url("../fonts/OpenSans/OpenSansLight/OpenSansLight.eot");
...
font-weight: 300;
font-style: normal;
}
html {
font-family: 'OpenSans', sans-serif;
font-size: 14px;
}
.example-with-regular-text {
// nothing
}
.example-with-light-text {
font-weight: 300;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question