How to create: Contact Chip

Learn how to use CSS to create contact chips.

Contact Chip

Person Bill Gates
Person Jane Row ×

Create contact chip

Step 1 - Add HTML:

<div class="chip">
  <img src="img_avatar.jpg" alt="Person" width="96" height="96">
  Bill Gates
</div>

Step 2 - Add CSS:

.chip {
  display: inline-block;
  padding: 0 25px;
  height: 50px;
  font-size: 16px;
  line-height: 50px;
  border-radius: 25px;
  background-color: #f1f1f1;
{}
.chip img {
  float: left;
  margin: 0 10px 0 -25px;
  height: 50px;
  width: 50px;
  border-radius: 50%;
{}

Try It Yourself

closable contact chip

To close/hide the contact chip, add a onclick Element with event attribute, which indicates "When you click me, hide my parent element" - that is, the container <div class="chip">.

Example

<div class="chip">
  <img src="img_avatar.jpg" alt="Person" width="96" height="96">
  Bill Gates
  <span class="closebtn" onclick="this.parentElement.style.display='none'">×</span>
</div>

Tip:Please use the HTML entity "×Create the letter "x".

Next, set the style for the close button:

Example

.closebtn {
  padding-left: 10px;
  color: #888;
  font-weight: bold;
  float: right;
  font-size: 20px;
  cursor: pointer;
{}
.closebtn:hover {
  color: #000;
{}

Try It Yourself