<fieldset>
    <legend>Login details:</legend>

    <div class="username">
        <label for="uname">Username:</label>
        <input type="text" id="uname" name="uname" required
               minlength="4" maxlength="8"
               placeholder="4 to 8 characters long" />
        <span class="validity"></span>
    </div>

</fieldset>

Output