Font Awesome and text both in placeholder

5.4k views Asked by At

i want to add the font awesome and texts in the placeholder in the following HTML code at the same time i want to know the process in details:

  <!DOCTYPE html>
<html>
<head>
    <title>Student-login</title>
    <link href='http://fonts.googleapis.com/css?family=Shadows+Into+Light' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" type="text/css" href="main.css">
    <link rel="stylesheet" type="text/css" href="css/font-awesome.min.css">
</head>
<body>
    <div class="body"></div>
        <div class="main-form">
            <h1>Student Login</h1>
            <form class="login">
                <input type="text" placeholder="*User name" name="username"></input><br>
                <input type="password" placeholder="*Password" name="password"></input><br>
                <input type="text" placeholder="*First name" name="first_name"></input><br>
                <input type="text" placeholder="*Last name" name="last_name"></input><br>
                <select name="gender">
                    <option value="">Select</option>
                    <option value="male">Male</option>
                    <option value="female">Female</option>
                </select><br>
                <input type="text" placeholder="*E-mail" name="email"></input><br>
                <input type="text" placeholder="*Phone number" name="phone"></input><br>
                <div class="button"><a href="index.html">Login</a></div>
                <div class="button"><a href="#">Submit</a></div>

            </form>
        </div>
</body>
</html>
1

There are 1 answers

2
Grokify On BEST ANSWER

To accomplish this, use FontAwesome as font by setting the CSS font-family to FontAwesome and referring to the icons you want using the FontAwesome Unicode reference.

For example, to have fa-envelope appear in a placeholder, you can use the following:

<style type="text/css">
    input {font-family:FontAwesome;}
</style>

<!-- use &#xf0e0; which is the code for fa-envelope -->
<input type="text" placeholder="&#xf0e0; E-mail" name="email" />