title: How to do floating of labels in CSS
body: <p>I want to display the label of an input inside its input, so that when I click the input, the label will animate and go above the input and change the styles of the input's border.</p>
  
  <p>Like so:</p>
  
  <p><a href="https://i.stack.imgur.com/L29q0.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/L29q0.jpg" alt="Enter image description here"></a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-css lang-css prettyprint-override"><code>* {
    margin: 0;
    padding: 0;
  }
  
  form {
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    outline: 1px solid lightgrey;
    padding: 10px;
  }
  
  label, input[type='text'], input[type='password'] {
    font-size: 12pt;
    padding: 8px;
  }
  
  label {
    color: grey;
  }
  
  input {
    border: none;
    outline: none;
    border-bottom: 1px solid grey;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form&gt;
    &lt;label for="username"&gt;Username&lt;/label&gt;
    &lt;input id="username" name="username" type="text"/&gt;
    &lt;br/&gt;
  
    &lt;label for="password"&gt;Password&lt;/label&gt;
    &lt;input id="password" name="password" type="password"/&gt;
    &lt;br/&gt;
  
    &lt;input type="submit" value"login"/&gt;
  &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>How can I achieve this with CSS?</p>