Monday, 29 May 2017

Web Fonts In CSS3

Web fonts allow you to  use fonts that are not installed on your computer. However, before creating the Web page you need a font file to use in your Web page.

For Example: Here we using a sample.ttf font file to use our Web page.

Create a Web page: wbfont.html

<!doctype html>
<head>
<title>Web fonts</title>
<style>
@font-face{
                     font-family:"Myfont";
                       src:url(sample.ttf) format("opentype");
                   }
           body{
                    font-family:myfont;
                       font-size:40px;
                  }
</style>
</head>
<body>
<h1>Working with web font in CSS3</h1>
<p>Here: We have used local font file named sample.ttf to use the font-style</p>
</body>
</html>

here we have define anew font with the name Myfont and use this font in the body element of the Web page.

The Browser View of webfont.html file:





No comments:

Post a Comment