简体   繁体   中英

How to embed font file in html?

I created simple form to give input in Preeti font.

<html>
  <body>
    <div>
      <center> <form>
        <label><b>Preeti : </b></label>
        <div class = "a"> <input type="text" name="message" id="user_input"> 
        </div>
        </form> </center>
      </html>
  </body>

I tried to embed Preeti font in css.

@font-face {
  font-family: "Preeti";
  src: url("fonts/preeti.eot");
  src: url("fonts/preeti.eot?#iefix") format("embedded-opentype"),
    url("fonts/preeti.otf") format("opentype"), 
    url("fonts/preeti.svg") format("svg"), 
    url("fonts/preeti.ttf") format("truetype"),
    url("fonts/preeti.woff") format("woff"), 
    url("fonts/preeti.woff2") format("woff2"); 
  font-weight: normal;
  font-style: normal;
}
.a {
  font-family: Preeti ;
}

Layout of form is above. 在此处输入图片说明

But When I give input,It don't type in Preeti font,It still type in normal English text.I want input in Preeti font.

This may work. Add this to your css file.

@font-face {
  font-family: 'Preeti';
  src: url('http://www.fontsaddict.com/fontface/preeti.TTF');
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM