<label for="user-id">User ID</label>
<input type="text" id="user-id">
Rendered Output
<label for="user-id">User ID</label>
<input type="text" id="user-id" placeholder="10 characters max">
Rendered Output
<input type="text" placeholder="User ID">
Rendered Output
<label for="user-id">User ID</label>
<input type="text" id="user-id" value="myid#123">
Rendered Output
<label for="user-id">User ID</label>
<input type="text" id="user-id" value="myid#123" disabled>
Rendered Output Trying to enter or change the value has no effect.
<label for="user-id">User ID</label>
<input type="text" id="user-id" value="myid#123" readonly>
Rendered Output Trying to enter or change the value has no effect.
<label for="user-id">User ID</label>

<!-- Limit input to a maximum of 10 characters with maxlength="10" -->
<input type="text" id="user-id" maxlength="10" placeholder="10 characters max">
Rendered Output
<form>
    <label for="nickname">Nickname</label>
    
    <!-- Require a minimum of 2 characters with minlength="2" -->
    <input type="text" id="nickname" minlength="2" placeholder="Enter 2+ characters..." required>
    <button type="submit">Submit</button>
</form>
Rendered Output Practice Guide: Checking How minlength Works
  • Check for Errors: Leave the input field empty or enter only 1 character, then click the [Submit] button. Confirm that the browser displays an error message indicating that the minimum input requirement (2 characters) has not been met.
  • Check for Success: Enter 2 or more characters in the field, then click the [Submit] button again. Confirm that the form is submitted without an error.
<form>
    <fieldset>
        <legend>Name is required</legend>
        <p>
            <label for="username">Name (*required)</label>
            <input id="username" type="text" required> <!-- Specify as a required input field -->
        </p>
        <p>
            <label for="userpassword">Password</label>
            <input id="userpassword" type="password">
        </p>
        <p>
            <button type="submit">Submit</button>
        </p>
    </fieldset>
</form>
Rendered Output Practice Guide: Checking How required Works
  • Check for Errors: Without entering anything in the Name (*required) field, click the [Submit] button. Confirm that the browser displays an error message for the required field.
  • Check for Success: Enter a value in the Name (*required) field, then click the [Submit] button again. Confirm that the form is submitted without an error.
<input type="text" pattern="Specify a regular expression">
<p>
    <label>
        No size attribute
        <input type="text">
    </label>
</p>
<p>
    <label>
        Short input
        <input type="text" size="5">
    </label>
</p>
<p>
    <label>
        Long input
        <input type="text" size="50">
    </label>
</p>
Rendered Output
<label for="fruits">Fruit Gift</label>
<input type="text" list="fruit-options" id="fruits">

<!-- Display in the drop-down menu -->
<datalist id="fruit-options">
    <option value="Apple"></option>
    <option value="Banana"></option>
    <option value="Cherry"></option>
    <option value="Date"></option>
</datalist>
Rendered Output Click the text box.