---
title: "How to add an icon as a placeholder in the input email box in bootstrap?"  
description: "How to add an icon as a placeholder in the input email box in bootstrap?"  
author: "Ashutosh Patel"  
published: 2024-10-14  
updated: 2024-10-14  
canonical: https://www.mindstick.com/interview/33970/how-to-add-an-icon-as-a-placeholder-in-the-input-email-box-in-bootstrap  
category: "html"  
tags: ["html", "css-css3", "html5"]  
reading_time: 2 minutes  

---

# How to add an icon as a placeholder in the input email box in bootstrap?

To set an icon as a placeholder in an input box using Bootstrap, you can use the following approach.

```html
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
   <title>Email Input with Icon</title>
   <style>
       .input-icon {
           position: relative;
       }
       .input-icon input {
           padding-left: 30px; /* Space for the icon */
       }
       .input-icon i {
           position: absolute;
           left: 10px;
           top: 50%;
           transform: translateY(-50%);
           color: #6c757d; /* Bootstrap's secondary color */
       }
   </style>
</head>
<body>
<div class="container mt-5">
   <h2>Set icon in input field</h2>
   <div class="input-icon">
       <i class="fas fa-envelope"></i>
       <input type="email" class="form-control" placeholder="Email address" aria-label="Email address">
   </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
```

![How to add an icon as a placeholder in the input email box in bootstrap?](https://www.mindstick.com/interviewquestion/cc465394-163a-48db-b41f-a0957a05a857/images/1f80259a-cd98-4401-9bb4-4f4c37f3bf31.jpg)

## Answers

### Answer by Ashutosh Patel

To set an icon as a placeholder in an input box using Bootstrap, you can use the following approach.

```html
<!DOCTYPE html>
<html lang="en">
<head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
   <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
   <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
   <title>Email Input with Icon</title>
   <style>
       .input-icon {
           position: relative;
       }
       .input-icon input {
           padding-left: 30px; /* Space for the icon */
       }
       .input-icon i {
           position: absolute;
           left: 10px;
           top: 50%;
           transform: translateY(-50%);
           color: #6c757d; /* Bootstrap's secondary color */
       }
   </style>
</head>
<body>
<div class="container mt-5">
   <h2>Set icon in input field</h2>
   <div class="input-icon">
       <i class="fas fa-envelope"></i>
       <input type="email" class="form-control" placeholder="Email address" aria-label="Email address">
   </div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>
```

![How to add an icon as a placeholder in the input email box in bootstrap?](https://www.mindstick.com/interviewquestion/cc465394-163a-48db-b41f-a0957a05a857/images/1f80259a-cd98-4401-9bb4-4f4c37f3bf31.jpg)


---

Original Source: https://www.mindstick.com/interview/33970/how-to-add-an-icon-as-a-placeholder-in-the-input-email-box-in-bootstrap

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
