Want to get away from ‘Web Safe’ fonts for some attractive headers AND do it without using an image? Use CSS3 font Embedding and embed a font-face!
NOTE: This article uses font file stored online and your browser may run slow or attempt to crash… sorry!
@font-face is not strictly speaking ‘CSS3′; it was originally born in CSS 2 and although not appearing in CSS 2.1, CSS 3 is attempting to bring it into the standards.
In order to use a font, we first must call it using the ‘@font-face’ attribute and this must be done for each individual font we wish to use. Although I’m sure you have a few, you can download some fonts to experiment with here, at dafont.com.
CSS 3 Embedded Font Face
HELLO CSS 3 WORLD!
The above header uses the SketchRockwell font with the following CSS 3 applied to it.
CSS 3 Font Embed (Example I)
@font-face { font-family: ‘SoftSugarplainRegular’; src: url(‘fonts/Softplain-webfont.ttf’); } .fontface { font: 40px ‘SoftSugarplainRegular’, Arial, sans-serif;; letter-spacing: 0; text-align:center; }
CSS3 can render type using several font formats: “truetype” (ttf),
“opentype” (otf), “embedded-opentype” (eot) and
“scalable-vector-graphic” (svg,svgz).
HELLO CSS 3 WORLD!
We can also apply additional effects such as a Text Shadow.
CSS 3 Font Embed (Example II)
@font-face { font-family: 'SoftSugarplainRegular'; src: url('fonts/Softplain-webfont.ttf'); } .fontface1 { font: 40px 'SoftSugarplainRegular', Arial, sans-serif; letter-spacing: 0; text-align:center; text-shadow: 3px 3px 7px #111; }
NOTE: For some reason, using both @font-face and text-shadow will cause problems in Google Chrome. The reason IE has been given a ‘?’ next to it for the @font-face attribute, is because it will work using the popular .eot font file.
Don’t forget to subscribe to our RSS-feed, follow us on Twitter and follow us on Facebook – for recent updates.
Very cool – I’d heard about this, but hadn’t tried it myself yet.
I’m curious about browser compatibility.
“NOTE: This article uses font file stored online and your browser may run slow or attempt to crash… sorry!” Is there a size limitation on fonts that causes that?
Hi Jay Lee
This method is compatible with all the browsers including IE. Do give a try to it