How to put fontello icon in input value?

Corey picture Corey · Jun 13, 2014 · Viewed 8.1k times · Source

Say I have this code:

<input type="submit" value="Send" />

But after the text "Send" I want to have a fontello icon. Obviously this doesn't work:

<input type="submit" value="Send <i class='icon-right-circle'></i>" />

In my fontello demo.html file, the code for that icon is 0xe81c. Isn't there a away to put this icon in the input value? Like as an HTML entity or something?

Thanks!

Answer

Fancyoung picture Fancyoung · Aug 26, 2014

This should work:

<input type="submit" value="Send &#xf001;" style="font-family:icons" />

There are two steps:

  1. use &#xf001; to output character. You can find code in fontello css file, someting like content:'\f001', just do the replace \f001 -> &#xf001;.

  2. set font-family for this element. I use icons in my code, you should check the font name in css file.


Further step: You can customize your own class:
.myfont { font-family:icons; }

and the html will be:
<input type="submit" value="Send &#xf001;" class="myfont" />