<search>
    <form method="get" action="/search">
        <label for="user-search">Search This Site</label>
        <input
            type="search"
            id="user-search"
            name="query">
        <button type="submit">Search</button>
    </form>
</search>
Rendered Output
<search>
    <form method="get" action="/search">
        <label for="user-search">Search This Site</label>
        <input 
            type="search" 
            id="user-search" 
            name="query" 
            placeholder="Enter a search term.">
        <button type="submit">Search</button>
    </form>
</search>
Rendered Output
<input type="search" value="search keyword">
Rendered Output
<input type="search" value="search keyword" disabled>
Rendered Output Trying to enter or change the value has no effect.
<input type="search" value="search keyword" readonly>
Rendered Output Trying to enter or change the value has no effect.
<!-- Limit input to a maximum of 10 characters with maxlength="10" -->
<input type="search" maxlength="10" placeholder="10 characters max">
Rendered Output
<form>
    <label for="search">Search Keyword</label>
    
    <!-- Require a minimum of 2 characters with minlength="2" -->
    <input type="search" id="search" minlength="2" placeholder="Enter 2+ characters..." required>
    <button type="submit">Search</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>Search Keyword is required</legend>
        <p>
            <label for="usersearch">Search Keyword (*required)</label>
            <!-- Specify as a required input field -->
            <input id="usersearch" type="search" required>
        </p>
        <p>
            <button type="submit">Search</button>
        </p>
    </fieldset>
</form>
Rendered Output Practice Guide: Checking How required Works
  • Check for Errors: Without entering anything in the Search Keyword (*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 Search Keyword (*required) field, then click the [Submit] button again. Confirm that the form is submitted without an error.
<input type="search" pattern="Specify a regular expression">
<p>
    <label>
        No size attribute
        <input type="search">
    </label>
</p>
<p>
    <label>
        Short input
        <input type="search" size="5">
    </label>
</p>
<p>
    <label>
        Long input
        <input type="search" size="50">
    </label>
</p>
Rendered Output
<label for="user-search">Search</label>
<input type="search" list="keywords" id="user-search">

<!-- Display in the drop-down menu -->
<datalist id="keywords">
    <option value="Company History"></option>
    <option value="Directions"></option>
    <option value="Contact Information"></option>
</datalist>
Rendered Output Click the search box.
<form method="get" action="/search">
    <input type="search" name="query" placeholder="Enter a search term.">
    <button type="submit">Search</button>
</form>
Rendered Output