How to Enrich Website Using @font-face?
There are many different fonts available to use across the internet. Google Web Fonts as we discussed provides a repository of highly optimized fonts for the web.
How do you add these custom fonts on website without using images, flash or some other graphics? What is the right way to add these fonts to your website? How to include and refer these fonts in your css file?
@font-face is a directive to the user agent (browser) to use the font specified using the @font-face at-rule. @font-face has become widely supported and is recommended for general use. It allows web authors to specify online fonts to display text on their web pages. It also eliminates the dependency on the limited number of fonts users have installed on their computers.
How to Embed Web fonts on pages using @Font-Face
All the font data are specified using a @font-face at-rule. You can specify different properties using different combination of “descriptor: value;” combination.
The general form is,
1 | @font-face { descriptor: value; } |
For example to specify font family you can use “font-family: “My font family”;” ?(without outer quotes).
The general syntax of @font-face is,
1 2 3 4 5 6 | @font-face {
font-family: <font-name-at-a-remote-location>;
src: <url-location-of-font> [,<url-location-of-font>]*;
[font-weight: <font-weight>];
[font-style: <font-style>];
} |
where
- <font-name-at-a-remote-location>
- <url-location-of-font>
- <font-weight>
- <font-style>
Specifies a font name .
URL for the remote font files location. This can also be the name of a font on the user’s computer in the form local (“Font Name”).
A font weight value.
A font style value.
See the example below
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <!doctype html public "-//w3c//dtd html 4.0//en">
<html>
<head>
<title>font test</title>
<style type="text/css" media="screen, print">
@font-face {
font-family: "some font";
src: url("http://site/somefontpath")
}
h1 { font-family: some font", serif }
</style>
</head>
<body>
<h1> this heading is displayed using some font</h1>
</body>
</html> |
In the above example the heading will appear in the font “some font“.
The below example shows how the local copy of “Helvetica Neue Bold” is used. If the font is not installed, then the downloadable font named “MgOpenModernaBold.ttf” is used.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <html>
<head>
<title>Web Font Sample</title>
<style type="text/css" media="screen, print">
@font-face {
font-family: TestHelveticaNeue;
src: local("Helvetica Neue Bold"),
local("HelveticaNeue-Bold"),
url(MgOpenModernaBold.ttf);
font-weight: bold;
}
body { font-family: "TestHelveticaNeue", serif }
</style>
</head>
<body>
This is TestHelveticaNeue Serif Bold.
</body>
</html> |
@font-face browser support
One important point to note here is the browser compatibility. IE9 supports WOFF (Web Open Font Format) but other versions support EOT (Embedded OpenType). Mozilla 3.5 and above supports OTF (Open Type Format), WOFF and TTF(TrueType Format) where as Safari and Opera support OTF, TTF and SVG and Google Chrome version 4 and above supports TTF, WOFF and SVG. TrueType and OpenType are superseded by WOFF format.
Sign up or join Globinch on Social Media
Stay Connected
Follow globinch
Popular Posts
- Search Engines for File Sharing Sites : Rapidshare Search, Megaupload and More 6 comment(s) | 16258 view(s)
- Turn your Windows 7 Computer Into a Personal Wi-Fi Hotspot 15 comment(s) | 16117 view(s)
- Google Translate Now supports Bengali, Gujarati, Kannada, Tamil and Telugu 2 comment(s) | 15714 view(s)
- Google Top Searches Today – Hot Google Search Words today 12 comment(s) | 11559 view(s)
- Best PDF OCR Tools to Convert Scanned images to Text / Word Documents 20 comment(s) | 10154 view(s)
- Globinch Search 0 comment(s) | 8402 view(s)
- Access Blocked sites, Unblock Restricted Websites 15 comment(s) | 7313 view(s)
- Free Online OCR Software to Convert Images Into Searchable PDF, Doc, HTML or Text 3 comment(s) | 7238 view(s)
- Password Revealer – How To Reveal- Show Password Behind Asterisks? 7 comment(s) | 7180 view(s)
- Play Angry Birds Game Free and Offline in Chrome Browser 1 comment(s) | 7049 view(s)
Recent Articles
- Best Free Tools to Enlarge Images without Losing Quality
- How to Track Your Gmail Email and Schedule Gmail Mail Free?
- Google Webmaster Unnatural Links Detected Warning & Penalty
- How to Use Trial Software Version Forever Without Expire
- How to Use Folder as Drive or Convert Folder to Drive?
- Add Buttons, Message Boxes and Text Highlights in WordPress Post
- Top 20 Free WordPress Social Share Plugins
- rel=”shortlink” Short URL Indicator and Its WordPress Support
- Pagination SEO Using rel=”next” and rel=”prev” Link Attributes
- Watch Live IPL 2012 Season 5 Online on Your Computer or Mobile









