Click here to Skip to main content
11,645,087 members (70,731 online)
Click here to Skip to main content

Create Stylish Webpage using CSS3 Custom Font

, 17 Jul 2013 CPOL 13.9K 27 7
Rate this:
Please Sign up or sign in to vote.
Make your website attractive using CSS3 Custom Fonts

Due to licensing issues, the font shown in the image below cannot be uploaded. You can obtain it for your personal use from here[^]. 

All of us want to create an attractive website but many of us don't know properly about How to change or use CSS Custom font. So, We are going to learn How to add various fonts to webpage. 

Let's Start:  

Download Fonts:

First Step is to Download the Font. There are many Websites which provide you thousands of Fonts at free of Cost. I am giving you some links.(I have no profit in sharing these links with you. You can find more on searching on google)

www.1001freefonts.com 

www.dafont.com 

Download the font which you like.

Convert the Font:

Why we require to convert the font(from .ttf to .eot)?

Answer is simple:- Actually most of our browser support .ttf font file except I.E. so if we want to see same font on I.E. also we have to convert it to .eot file. I am providing you a link by which you can convert .ttf to .eot.

Free online .ttf to .eot Converter

Here you have to just upload the font file (.ttf) and convert it to .eot. After converting Download your .eot font file.

Applying Fonts to Web Page: 

<body>
<p class="new">Anoop Kumar Sharma</p>
</body>

 I have created a page in Html and add a class .new for applying fonts that i have downloaded earlier.

Preview:

 

CSS: 

@font-face
{
font-family:defused;/*Supported by major browser*/
src:url("defused.ttf");
}
@font-face
{
font-family:defused;/*for I.E. only*/
src:url("defused.eot");
}
.new
{
font-family:defused;
font-size:40px;
} 

Here using @font-face we can set Source and name to our font.

In above code I have added both .ttf and .eot file so that if user visit my page using I.E or other browser than same font appear to him on webpage.

Finally I apply the font on .new class.

Preview:

 

That's all.

Hope you like it. 

Please view my other Tips/tricks:

Create Stylish Search Button 

Stylish Glowing button  

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Anoop Kr Sharma
Student
India India

You may also be interested in...

Comments and Discussions

 
GeneralMy vote of 3 Pin
Amir Mohammad Nasrollahi25-Jul-13 20:50
professionalAmir Mohammad Nasrollahi25-Jul-13 20:50 
GeneralRe: My vote of 3 Pin
Anoop Kr Sharma26-Jul-13 5:53
professionalAnoop Kr Sharma26-Jul-13 5:53 
GeneralMy vote of 3 Pin
nosferatu197923-Jul-13 2:15
membernosferatu197923-Jul-13 2:15 
GeneralRe: My vote of 3 Pin
Anoop Kr Sharma23-Jul-13 7:46
professionalAnoop Kr Sharma23-Jul-13 7:46 
GeneralMy vote of 5 Pin
VitorHugoGarcia18-Jul-13 6:52
memberVitorHugoGarcia18-Jul-13 6:52 
GeneralRe: My vote of 5 Pin
Anoop Kr Sharma18-Jul-13 8:04
professionalAnoop Kr Sharma18-Jul-13 8:04 
GeneralMy vote of 5 Pin
Leroy J. Gibbs17-Jul-13 21:59
professionalLeroy J. Gibbs17-Jul-13 21:59 
GeneralRe: My vote of 5 Pin
Anoop Kr Sharma18-Jul-13 8:03
professionalAnoop Kr Sharma18-Jul-13 8:03 
GeneralApologizing for mistake Pin
Anoop Kr Sharma17-Jul-13 8:33
professionalAnoop Kr Sharma17-Jul-13 8:33 
GeneralRe: Apologizing for mistake Pin
Pete O'Hanlon17-Jul-13 10:24
protectorPete O'Hanlon17-Jul-13 10:24 
It takes a good person to admit a mistake. Well done to you, and have a 5 from me.
I was brought up to respect my elders. I don't respect many people nowadays.

CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

GeneralMy vote of 1 Pin
ThePhantomUpvoter17-Jul-13 3:33
professionalThePhantomUpvoter17-Jul-13 3:33 
GeneralRe: My vote of 1 Pin
Leroy Gibbs18-Jul-13 0:17
professionalLeroy Gibbs18-Jul-13 0:17 
GeneralMy vote of 1 Pin
H. Mueller16-Jul-13 20:40
professionalH. Mueller16-Jul-13 20:40 
GeneralRe: My vote of 1 Pin
Anoop Kr Sharma17-Jul-13 8:30
professionalAnoop Kr Sharma17-Jul-13 8:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150731.1 | Last Updated 17 Jul 2013
Article Copyright 2013 by Anoop Kr Sharma
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid