Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I load external fonts into an HTML document?

Tags:

html

fonts

How do I load external font files into an HTML document.

Example: Make the text "blah blah blah blah blah blah blah" a custom font from a TTF file in the same directory using HTML CSS and/or JAVASCRIPT

like image 696
Eric Avatar asked Feb 10 '10 14:02

Eric


People also ask

How do I load a TTF font in HTML?

Add your font file.Use the src=url () property in between the parenthesis of the @font-face{} property, mentioning the font file in between the parenthesis of the src=url () property. CSS accepts TTF, OTF, WOFF, SVG, and EOT font-file formats.

How do I import a font from Google to HTML?

To add google fonts, search for the google fonts, select the font category and family, then select the font style of your choice. Once you select the font, “copy the font link”, from the “selected families windows” and paste it in the head section of the HTML file.

What fonts does HTML support?

Best Web Safe Fonts for HTML and CSSArial (sans-serif) Verdana (sans-serif) Tahoma (sans-serif) Trebuchet MS (sans-serif)


1 Answers

Take a look at this A List Apart article. The pertinent CSS is:

@font-face {   font-family: "Kimberley";   src: url(http://www.princexml.com/fonts/larabie/kimberle.ttf) format("truetype"); } h1 { font-family: "Kimberley", sans-serif } 

The above will work in Chrome/Safari/FireFox. As Paul D. Waite pointed out in the comments you can get it to work with IE if you convert the font to the EOT format.

The good news is that this seems to degrade gracefully in older browsers, so as long as you're aware and comfortable with the fact that not all users will see the same font, it's safe to use.

like image 183
Chris Van Opstal Avatar answered Sep 30 '22 07:09

Chris Van Opstal