CSS Website Fonts

Font Face Rules

Good for using on computer , and also across the web.

Custom fonts are defined within the CSS with  a rule:@font-face

Font Format Types

TrueType Fonts (TTF)

TrueType is a font standard developed in the late 1980s, by Apple and Microsoft. TrueType is the most common font format for both the Mac OS and Microsoft Windows operating systems.

OpenType Fonts (OTF)

OpenType is a format for scalable computer fonts. It was built on TrueType, and is a registered trademark of Microsoft. OpenType fonts are used commonly today on the major computer platforms.

The Web Open Font Format (WOFF)

WOFF is a font format for use in web pages. It was developed in 2009, and is now a W3C Recommendation. WOFF is essentially OpenType or TrueType with compression and additional metadata. The goal is to support font distribution from a server to a client over a network with bandwidth constraints.

The Web Open Font Format (WOFF 2.0)

TrueType/OpenType font that provides better compression than WOFF 1.0.

SVG Fonts/Shapes

SVG fonts allow SVG to be used as glyphs when displaying text. The SVG 1.1 specification define a font module that allows the creation of fonts within an SVG document. You can also apply CSS to SVG documents, and the @font-face rule can be applied to text in SVG documents.

Embedded OpenType Fonts (EOT)

EOT fonts are a compact form of OpenType fonts designed by Microsoft for use as embedded fonts on web pages.


 

Font Supported Browsers – More Info

To make sure all the browsers are supported , advised to use all the types in coersion:

 

@font-face {
font-family: 'MywebyFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('webfont.woff2') format('woff2'), /* Super Modern Browsers */ url('webfont.woff') format('woff'), /* Pretty Modern Browsers */ url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */ url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */ }
}
body { font-family: 'MywebyFont', Fallback, sans-serif; }

 

Importing Fonts to CSS

@font-face {
font-family: HarbaraMais;
src: url(http://dev-site.com/wp-content/uploads/font/Harabara_Mais_Demo.otf);
font-weight: normal, bold, 100, 200, 300, 400, 500, 600, 700, 800, 900;
}

.title {
font-family: HarbaraMais;
}

Similar approach

styles.cssimport "work-font.css";
@import url('https://fonts.googleapis.com/css2?family=Work+Sans:wght@300&display=swap');

work-font.css/* latin */
@font-face {
font-family: 'Work Sans';
font-style: normal;
font-weight: 100;
src: url(https://fonts.gstatic.com/s/worksans/v8/QGYsz_wNahGAdqQ43Rh_fKDp.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-  206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

Was this article helpful?

Related Articles

Leave A Comment?