html import font code example
Example 1: import font css
@font-face {
font-family: "Open Sans";
src: url("/fonts/OpenSans-Regular-webfont.woff2") format("woff2"),
url("/fonts/OpenSans-Regular-webfont.woff") format("woff");
}
Example 2: how to link fonts css
@font-face {
font-family: myFirstFont;
src: url(sansation_light.woff);
}
div {
font-family: myFirstFont;
}
Example 3: css font face
@font-face {
// Defining what the font will be called
font-family: thisSpecialFont;
// Linking to the font file
src: url(linkToFontFile.woff);
}
body {
font-family: thisSpecialFont;
}
Example 4: how to add font otf format in html
@font-face {
font-family: 'lovelyFont';
src: url('fonts/lovely_font.eot');
src:
local('Lovely Font'),
local('Lovely-Font'),
url('fonts/lovely_font.otf')
format('opentype');
}
@font-face {
font-family: 'lovelyFont';
src: url('fonts/lovely_font_bold.eot');
src:
local('Lovely Font Bold'),
local('Lovely-Font-Bold'),
url('fonts/lovely_font_bold.otf')
format('opentype');
font-weight: bold;
}
div { font-family: 'lovelyFont', sans-serif; }
span { font-weight: bold; }