CSS Font Face

Note: Before reading this article, you need to know about CSS Font Family. I assume you know about the CSS font family.

Font Face is a great feature of CSS. Think You like a font you want to use, what next? Yes, that’s why Fontface.

Fontface is writt…


This content originally appeared on DEV Community and was authored by Rezaul karim??

Note: Before reading this article, you need to know about CSS Font Family. I assume you know about the CSS font family.

Font Face is a great feature of CSS. Think You like a font you want to use, what next? Yes, that's why Fontface.

Fontface is written in CSS. And you have to write as follows:

@font-face
{
font-family: FontFace;
src: url('MyFavoriteFont.ttf')
 ,url('MyFavoriteFont.eot'); /* For IE */
}

font-family: FontFace; You can name your font family with this. You can give any name instead of FontFace. And later you can use the CSS font the way Family uses it: font-family: FontFace;

Add the url of your font with src: url (‘MyFavoriteFont.ttf’). IE does not support ttf [True Type Font]. For that you have to use eot (Embedded OpenType) font. For this we have added utl of eot font with a comma. If you do not have eot font, then you can get it by doing a little search on Google.

Our fontface is ready. Now we can use it anywhere. As much as you want.

To use, you have to write the font family as you write it

.myDiv
{
font-family:FontFace;
}

And the whole example:

<!DOCTYPE html>
<html>
<head>
<style>
@font-face
{
font-family: FontFace;
src: url('MyFavoriteFont.ttf')
 ,url('MyFavoriteFont.eot'); /* For IE */
}

.myDiv
{
font-family:FontFace;
}
</style>
</head>
<body>

<div class="myDiv">
Some text with CSS3 Font Face feature.
</div>

</body>
</html>

Enter the name of your font in place of ‘MyFavoriteFont.ttf’. Note: You must enter the url where you will upload the fonts. Now if you open a directory with fonts and put the fonts in it, you have to type ‘fonts / MyFavoriteFont.ttf’ etc.
If you don't want to bother so much, you can use it in a simpler way. There are many fonts uploaded to Google Web Fonts. http://www.google.com/fonts/

You can use it by going here and selecting the font of your choice and clicking on the Quick Use button. Add the following link to the header section of your site:

<link href='http://fonts.googleapis.com/css?family=Caesar+Dressing' rel='stylesheet' type='text/css'>

Nothing more to do. Then just add the name of the font to the fontfamily: font-family: ‘Caesar Dressing’, cursive;

<!DOCTYPE html>
<html>
<head>
<link href='http://fonts.googleapis.com/css?family=Sonsie+One' rel='stylesheet' type='text/css'>
<style>
.myDiv
{
font-family: 'Sonsie One', cursive;
text-align:center;
margin-top:10%;
color:#808080;
}
</style>
</head>
<body>

<div class="myDiv">
Some text with CSS3 Font Face feature.
</div>

</body>
</html>

You can also read:

For more exciting tips and tricks about programming and coding please read our others articles

Find My page on Instagram: @stack.content

Find Me on Twitter: @mrezaulkarim_


This content originally appeared on DEV Community and was authored by Rezaul karim??


Print Share Comment Cite Upload Translate Updates
APA

Rezaul karim?? | Sciencx (2021-09-28T15:10:57+00:00) CSS Font Face. Retrieved from https://www.scien.cx/2021/09/28/css-font-face/

MLA
" » CSS Font Face." Rezaul karim?? | Sciencx - Tuesday September 28, 2021, https://www.scien.cx/2021/09/28/css-font-face/
HARVARD
Rezaul karim?? | Sciencx Tuesday September 28, 2021 » CSS Font Face., viewed ,<https://www.scien.cx/2021/09/28/css-font-face/>
VANCOUVER
Rezaul karim?? | Sciencx - » CSS Font Face. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/28/css-font-face/
CHICAGO
" » CSS Font Face." Rezaul karim?? | Sciencx - Accessed . https://www.scien.cx/2021/09/28/css-font-face/
IEEE
" » CSS Font Face." Rezaul karim?? | Sciencx [Online]. Available: https://www.scien.cx/2021/09/28/css-font-face/. [Accessed: ]
rf:citation
» CSS Font Face | Rezaul karim?? | Sciencx | https://www.scien.cx/2021/09/28/css-font-face/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.