How TO - Contact Chips


Learn how to create contact chips with CSS.


Contact Chips

Person John Doe
Person Jane Row ×

Create Contact Chips

Step 1) Add HTML:

Example

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

Step 2) Add CSS:

Example

.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 Chips

To close/hide the contact chip, add an element with an onclick event attribute that says "when you click you on me, hide my parent element" - which is the container div (class="chip").

Example

<div class="chip">
  <img src="img_avatar.jpg" alt="Person" width="96" height="96">
  John Doe
  <span class="closebtn" onclick="this.parentElement.style.display='none'">&times;</span>
</div>

Tip: Use the HTML entity "&times;" to create the letter "x".

Next, style 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 »

Copyright 1999-2023 by Refsnes Data. All Rights Reserved.