<!-- Use at your own risk -->
<form class="place">
  <div class="form-row">
    <input class="inp" id="firstname" type="text" required placeholder="Enter your first name">
    <label class="placehold" for="firstname">Enter your <b>First Name</b> <small>(Required)</small></label>
  </div>
  <div class="form-row">
    <input class="inp" id="email" type="email" required placeholder="Enter your email address">
    <label class="placehold" for="email">Enter your <b>Email Address</b> <small>(Required)</small></label>
  </div>
  <div class="form-row">
    <input class="inp optional" id="nickname" type="text" placeholder="Enter your Nickname">
    <label class="placehold" for="nickname">Enter your <b>Nickname</b> <small>(optional)</small></label>
  </div>
  <div class="form-row">
    <select required class="inp" id="relationshipCode" name="relationshipCode" value="">
      <option></option>
      <option>1</option>
      <option>2</option>
    </select>
    <label class="placehold" for="relationshipCode">Your Relationship to the Insured</label>
  </div>
  <input type="submit">
</form>
html {
  box-sizing: border-box;
}
*,
*:before,
*:after {
  box-sizing: inherit;
}
.place {
  max-width: 600px;
  margin: auto;
  padding: 10px;
  background: #f9f9f9;
}
.form-row {
  display: flex;
  position: relative;
  margin: 20px 0 40px;
}
.inp {
  width: 100%;
  flex: 1 0 100%;
  height: 40px;
  line-height: 20px;
  font-size: 1rem;
  padding: 0 10px;
  background:white;
  border-radius:0;
  border:1px solid #ccc;
}
.placehold {
  position: absolute;
  left: 0;
  top: 0;
  padding: 0 11px;
  height: 40px;
  line-height: 40px;
  font-size: 1rem;
  opacity: 0.7;
  transition: all 0.3s ease;
}
.placehold b {
  color: blue;
}
.inp:focus + .placehold,
.inp:valid + .placehold {
  transform: translateY(-95%);
}
.inp:placeholder {
  visibility: hidden;
}

.inp::-webkit-input-placeholder {
  /* Chrome/Opera/Safari */
  color: transparent;
}
.inp::-moz-placeholder {
  /* Firefox 19+ */
  color: transparent;
}
.inp:-ms-input-placeholder {
  /* IE 10+ */
  color: transparent;
}
.inp:-moz-placeholder {
  /* Firefox 18- */
  color: transparent;
}
.inp:placeholder {
  /* No spec for this yet!! */
  color: transparent;
}
.inp:not(:placeholder-shown) + .placehold {
  transform: translateY(-95%);
}
.inp:invalid:not(:placeholder-shown) + .placehold b:after {
  content: " - Error";
  color: red;
  font-weight: bold;
}

/* code for optional input*/
.inp.optional:placeholder-shown + .placehold {
  transform: translateY(0%);
}
.inp.optional:not(:placeholder-shown) + .placehold {
  transform: translateY(-95%);
}
.inp.optional:focus + .placehold {
  transform: translateY(-95%);
}


/* selects */
select{-webkit-appearance: menulist-button;}/* safari*/

select.inp:not(:valid) + .placehold {
  transform: translateY(0%);
}
/* remove this last :focus rule if you don't want label to move until a valid item is selected */
select.inp:focus + .placehold {
  transform: translateY(-95%);
}


Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.