DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
ThatPainter
CSS

Free Search Form Examples: HTML, CSS, and jQuery Patterns

The SmashingApps search-form roundup is a useful 2015 design gallery, not a verified modern component library. Learn how to choose a pattern, build an accessible form, and assess old demos, dependencies, and licenses.

By ThatPainter Team 9 min read
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

ThatPainter is reader-supported. When you buy through links on our site, we may earn an affiliate commission. Learn More

Search forms range from a plain field that submits to a results page to animated headers, autocomplete, and filters for content already on screen. The SmashingApps collection titled “Free Collection Of HTML5, CSS3 & jQuery Search Forms” was published on January 5, 2015, and is best treated as a historical source of design ideas—not a current, verified library of working demos. Its examples include suggestion dropdowns, expanding and animated inputs, CSS-only forms, mobile designs, Google-powered search, jQuery plugins, and local filtering. Each linked demo, download, dependency, and license needs its own current check. See the original collection.

As an Amazon Associate I earn from qualifying purchases.

The practical rule is simple: choose the interaction that fits the job, then connect it to real search behavior. Styling alone does not search a site. A semantic HTML form is usually the right starting point; JavaScript is an enhancement for behaviors such as local filtering, autocomplete, or an expanding field.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What kind of search form do you need?

“Search form” can mean several different things. The distinction matters because a polished field is not necessarily connected to searchable data.

  • Site search: submits a query to a results page or search endpoint, which retrieves content from a site or service.
  • Content filter: hides or shows items already available in the current page or browser dataset. It does not search unloaded pages or the rest of a website.
  • Autocomplete: offers possible queries or records as someone types. Suggestions are an enhancement, not a substitute for submitting a query.
  • Expandable search: begins as a compact field or trigger and reveals more of the form when activated.
  • Visual-only design: demonstrates appearance or animation without a working search destination.
  • External search integration: sends the query to a hosted provider or search engine, with its own integration and data considerations.
  • Advanced search: adds filters such as category, date range, scope, facets, or sorting.

The 2015 roundup mixes several of these, including a “Mini Search Filter,” Google-powered site search, suggestions, animated inputs, and CSS-only forms. Treat each as a pattern to inspect, not as proof of a complete search system.

Choose a pattern by use case

Pattern Best fit Main trade-off
Standard inline form Most sites, blogs, documentation, and stores Needs deliberate styling to suit the surrounding interface.
Full-width field Mobile layouts, documentation, and content-heavy pages Can take more vertical space than the task warrants.
Expandable field Compact headers or navigation bars A concealed control may be hard to discover or operate.
Search with suggestions Catalogs, help centers, and large datasets Needs keyboard behavior, loading and error states, and careful request handling.
Client-side filter A small visible list or table already loaded on the page Cannot search records that have not been loaded.
Search with scope selector Large sites or stores with meaningfully different content areas Adds choices and implementation complexity.
Animated search Visual showcases or interfaces where motion has a clear purpose Can obscure focus or reduce usability if motion and state changes are not managed.
Icon-only trigger Severely space-constrained interfaces Requires a clear accessible name and sufficient discoverability.
External search service Large or frequently changing collections needing indexed search Brings integration work, vendor or infrastructure considerations, and privacy questions.

For a new lightweight project, start with semantic HTML and CSS. Add JavaScript only for a behavior the basic form cannot provide. If the complete searchable list is already on one page, a local filter may be enough. If results are large, paginated, permission-dependent, or need ranking and typo tolerance, use a server-side or hosted search system instead.

Build a real form before styling it

A basic site search needs a form destination, a named input, an associated label, and a submit button. The following example assumes the site accepts a GET query parameter named q; replace /search and the parameter name with the route and contract your site actually uses.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<form action="/search" method="get" role="search">
  <label for="site-search">Search this site</label>
  <input
    type="search"
    id="site-search"
    name="q"
    placeholder="Search the site…"
  >
  <button type="submit">Search</button>
</form>

A real form lets users submit with Enter and gives the browser ordinary form behavior. MDN documents <input type="search">, its standard input attributes, and its connection to suggestions through list and <datalist>: MDN: search input. GET is suitable for ordinary searches when the query can safely appear in the URL; it is shareable and bookmarkable, but URLs may also be recorded in browser history, logs, or analytics.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

Use an explicit <label for="…"> association, matching the input’s id. W3C recommends labels for form controls and documents this explicit relationship as a reliable labeling method: W3C: Labeling controls. A placeholder is a hint, not a durable replacement for a label; it disappears as the user types and may have weak contrast. W3C: Form instructions.

When the design has no room for a visible label

Prefer a visually hidden label that remains available to assistive technology. If an icon button submits the form, provide the button an accessible name and mark a purely decorative icon as hidden from assistive technology.

<form action="/search" method="get" role="search">
  <label class="visually-hidden" for="search-query">
    Search this site
  </label>
  <input id="search-query" name="q" type="search">
  <button type="submit" aria-label="Submit search">
    <svg aria-hidden="true" viewBox="0 0 24 24">
      <!-- decorative search icon -->
    </svg>
  </button>
</form>

W3C explains that aria-label is not conveyed to sighted users and that title is less reliable as a substitute for a label; use those approaches only when their limitations are understood. W3C APG: Names and descriptions. A search icon on its own is not an accessible name for an input.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Style the form responsively

Flexbox is a straightforward way to align an input and submit button. Let the input shrink with min-width: 0, preserve visible keyboard focus, and allow the layout to stack when there is not enough horizontal space.

.search-form {
  display: flex;
  gap: 0.5rem;
  width: min(100%, 40rem);
}

.search-form input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.75rem 1rem;
  border: 2px solid #697586;
  border-radius: 0.5rem;
  font: inherit;
}

.search-form button {
  flex: 0 0 auto;
  padding: 0.75rem 1rem;
  border: 0;
  border-radius: 0.5rem;
  background: #155eef;
  color: #fff;
  font: inherit;
  cursor: pointer;
}

.search-form input:focus-visible,
.search-form button:focus-visible {
  outline: 3px solid #fdb022;
  outline-offset: 2px;
}

.search-form:focus-within {
  /* Optional compound-field styling when a child receives focus. */
}

@media (max-width: 30rem) {
  .search-form {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  .search-form,
  .search-form * {
    scroll-behavior: auto;
    transition-duration: 0.01ms;
    animation-duration: 0.01ms;
  }
}

Use colors with sufficient contrast for text, borders, icons, and focus indicators, and make controls comfortable to use by touch. CSS custom properties can centralize colors, borders, and spacing; clamp() can make sizes fluid within sensible bounds. Logical properties such as padding-inline help when layouts need to support different writing directions. Keep animation restrained and honor reduced-motion preferences.

Use expanding and animated forms carefully

An expanding input can save header space, but it must remain an ordinary, operable form. Make the trigger a real button with a visible focus state; expose whether it is expanded, connect it to the field where appropriate, and let keyboard users open and close it. When opening, move focus to the revealed input only if that is the expected interaction, and ensure the animation does not clip the field or cover other controls. The form should still have a useful no-JavaScript path rather than hiding the only search control until a script runs.

  • Keep the search affordance recognizable and discoverable.
  • Do not move focus unexpectedly or strand keyboard users in a hidden field.
  • Check the expanded state at narrow widths and with long queries.
  • Respect reduced-motion settings; animation should not be required to understand or use the form.

CSS can style and animate the form, but it cannot retrieve site content by itself. A CSS-only example can still submit through normal HTML when its form action is real; a purely visual effect is not a search implementation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Add suggestions without breaking submission

For a small, predefined set of terms, a native <datalist> may be enough. For server-backed autocomplete, suggestions need deliberate behavior: debounce requests, avoid unnecessary lookups for empty or very short queries, and support keyboard movement, selection, Enter, and Escape. Keep the typed query if suggestions are dismissed, and do not force a selection before ordinary form submission.

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers

Show loading, no-match, and error states when requests are asynchronous. Prevent a slow response to an older query from replacing newer suggestions, and communicate results without announcing every keystroke. A suggestion list should be usable by keyboard and understandable to assistive technology; building this well is more than placing a dropdown under an input. The underlying form should remain submit-capable if JavaScript or the suggestions service fails.

Use local filtering only for local data

This vanilla JavaScript example filters list items already rendered in the document and updates a polite result count:

<label for="filter">Filter products</label>
<input id="filter" type="search" autocomplete="off">
<p id="result-count" aria-live="polite"></p>

<ul id="products">
  <li data-search="red cotton shirt">Red cotton shirt</li>
  <li data-search="blue wool jacket">Blue wool jacket</li>
  <li data-search="black linen trousers">Black linen trousers</li>
</ul>

<script>
const input = document.querySelector("#filter");
const items = [...document.querySelectorAll("#products li")];
const count = document.querySelector("#result-count");

function updateResults() {
  const query = input.value.trim().toLocaleLowerCase();
  let visible = 0;

  for (const item of items) {
    const matches = item.dataset.search.toLocaleLowerCase().includes(query);
    item.hidden = !matches;
    if (matches) visible++;
  }

  count.textContent = query
    ? `${visible} result${visible === 1 ? "" : "s"}`
    : `${items.length} results`;
}

input.addEventListener("input", updateResults);
updateResults();
</script>

This example matches substrings in the supplied data-search values. It does not search the rest of a website, unloaded records, paginated results, or data available only through an API. For large datasets, permission-sensitive records, rapidly changing content, ranking, stemming, synonyms, typo tolerance, or facets, move retrieval to an appropriate search service or backend. Search features such as spelling correction, stemming, and synonyms can help users locate content; W3C discusses search-function guidance here: W3C: Providing a search function.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Decide whether jQuery belongs in the project

jQuery can make sense when the application already depends on it or a compatible plugin is part of an established codebase. It can help with event binding, DOM traversal, and Ajax in legacy applications. It is not required by the phrase “HTML5, CSS3, and jQuery,” and it is unnecessary as a new dependency for a basic form, small local filter, or simple expansion effect that browser APIs can handle.

Before adopting a jQuery example, identify the required jQuery version and any other libraries, inspect the source, and check whether the code uses obsolete APIs or depends on external assets that remain available. A plugin’s attractive appearance does not establish current maintenance, accessibility, or browser compatibility. Avoid adding a large dependency for one small interaction.

Audit an older demo before adapting it

The original roundup presents titles and links rather than a modern audit of each implementation. Its age alone does not prove an example is broken, but neither does a reachable page establish that it is safe or production-ready. Check each candidate directly:

  • Does the demo load, and does the download or source code remain available?
  • Does the control submit a real query, filter local items, fetch suggestions, or only animate?
  • What libraries and versions does it require? Are dependencies still served securely and maintained?
  • Does it work at narrow screen widths and with keyboard-only operation?
  • Is there a visible or programmatic label, a visible focus indicator, and appropriate result or error feedback?
  • Does it handle empty, long, partial, and unmatched queries, as well as slow or failed requests?
  • Does it work when JavaScript is unavailable, if ordinary form submission should be possible?
  • Are the source and license explicit, and do included fonts, icons, images, or plugins have separate terms?

Older examples may rely on vendor-prefixed CSS, deprecated jQuery patterns, insecure HTTP assets, missing libraries, unpinned CDN files, or layout assumptions that fail on mobile. Treat such code as a visual reference until it has been inspected and adapted.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Check what “free” covers

A free-to-view demo is not automatically free to download, reuse commercially, or redistribute. Confirm the terms for the code and every bundled asset before using an example in a project. Look for:

  • Whether source code is actually available and downloadable.
  • Permission for commercial use and any attribution requirement.
  • Separate licenses for fonts, icons, images, plugins, and other dependencies.
  • Whether the demo relies on a paid API or external service even if its front-end code is free.
  • When the source or dependency was last updated and whether the demo still works.

The original collection’s “free” framing concerns design resources; it does not establish the license of every linked item or cover hosting, third-party assets, API usage, or search infrastructure.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

More from the Paint Desk

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.