Label_Better.js – The Best Way To Label Your Input Fields In Web Forms

Editor's note (2026): This post is from 2014, and the Label_Better.js plugin is no longer maintained. We've also added an important correction: placeholders should never replace real labels, because screen readers and many users depend on visible, properly connected labels. See the modern approach at the end.

Forms and input fields are part of nearly every website. HTML5 introduced the placeholder attribute, which shows hint text inside a field. Many designers used placeholders instead of labels to save space.

The problem: once users start typing, the placeholder disappears. In a filled-in form, it's hard to tell which field is which.

How Label_Better.js helped

The Label_Better.js jQuery plugin took a field's placeholder text and turned it into a small label that appears only when needed:

  1. When a field is focused, the plugin grabs the placeholder text, creates a label element, and animates it into view with CSS3.
  2. When the field loses focus, the plugin checks whether it has a value. If it's empty, the label is removed; if it has content, the label stays.

Setup

$("input.label_better").label_better({
  position: "top",
  animationTime: 500,
  easing: "ease-in-out",
  offset: 20
});

Set each field's label position with a data-position attribute:

<input type="text" class="label_better" data-position="top" placeholder="Username">
<input type="text" class="label_better" data-position="right" placeholder="Email Address">

The modern, accessible approach

Today, use a real <label> for every field and create the "floating label" effect with CSS alone:

<div class="field">
  <input id="email" type="email" placeholder=" " required>
  <label for="email">Email address</label>
</div>
.field { position: relative; }
.field label {
  position: absolute;
  left: 0.75rem;
  top: 0.75rem;
  transition: transform 0.2s, font-size 0.2s;
  pointer-events: none;
}
.field input:focus + label,
.field input:not(:placeholder-shown) + label {
  transform: translateY(-1.4rem);
  font-size: 0.75rem;
}

The label is always present for screen readers, stays visible once the user types, and needs no JavaScript.


Need help making your website's forms easier to use and accessible? I.T. For Less can help — contact us.

Development