The search experience
A search page contains many components and elements documented elsewhere. This page is about how to put them together, the hierarchy of content, and other design considerations when building a search form and results page.
Before a search
Before a search, the form is the primary content so it sits on the default page ground (white in light mode). Tips for searching are secondary content and sit in a tinted band below it.
Note
Meets accessibility guideline WCAG 2.2 SC 1.3.1 Info and Relationships (Level A)
Search
Search tips
How to search by author, by category, with wildcards and phrases.
Relevant code
<main class="ds-container">
<h1>Search</h1>
<form class="ds-form--compact" method="get" action="search.html" role="search" aria-label="Search arXiv">
<div class="ds-input-group">
<label class="is-sr-only" for="sq1">Search term</label>
<input class="ds-input" id="sq1" name="query" type="search" value="">
<label class="is-sr-only" for="sf1">Field to search</label>
<select class="ds-input" id="sf1" name="searchtype"><option>All fields</option><option>Title</option><option>Author(s)</option><option>Abstract</option></select>
</div>
<button class="ds-btn ds-btn-primary" type="submit">Search</button>
<label class="ds-check"><input type="checkbox" name="abstracts" value="show" checked><span>Show abstracts</span></label>
<a href="search.html">Advanced search</a>
</form>
<div class="ds-full ds-zone-secondary">
<h2>Search tips</h2>
<p>How to search by author, by category, with wildcards and phrases.</p>
</div>
</main>
- <h1>
- The page heading. The demo here uses smaller headings because it sits inside this page.
- <h2> in the band
- The heading for the help.
- .ds-form--compact
- The search form. See Compact form.
- .ds-full.ds-zone-secondary
- The help, in a tinted band. See Secondary zones.
After a search
After a search, the form stays where it was, on the page ground. A heading names the query, and tinted bars with the range and page numbers bookend the results.
Search
Results for “lensing”
Search shows the first 10,000 results. To see the rest, narrow the search.
- The first result
- The last result on this page
Relevant code
<main class="ds-container">
<h1>Search</h1>
<form class="ds-form--compact" method="get" action="search.html" role="search" aria-label="Search arXiv">
<div class="ds-input-group">
<label class="is-sr-only" for="sq2">Search term</label>
<input class="ds-input" id="sq2" name="query" type="search" value="lensing">
<label class="is-sr-only" for="sf2">Field to search</label>
<select class="ds-input" id="sf2" name="searchtype"><option>All fields</option><option>Title</option><option>Author(s)</option><option>Abstract</option></select>
</div>
<button class="ds-btn ds-btn-primary" type="submit">Search</button>
<label class="ds-check"><input type="checkbox" name="abstracts" value="show" checked><span>Show abstracts</span></label>
<label>Sort by <select class="ds-input" name="order"><option>Newest announced</option><option>Relevance</option></select></label>
<label>Per page <select class="ds-input" name="size"><option>25</option><option selected>50</option><option>100</option></select></label>
<a href="search.html">Advanced search</a>
</form>
<section aria-labelledby="results">
<h2 id="results">Results for “lensing”</h2>
<div class="ds-alert">
<svg class="ds-alert-icon" viewBox="0 0 24 24" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><circle cx="12" cy="12" r="10"/><path d="M12 16v-4"/><path d="M12 8h.01"/></svg>
<div class="ds-alert-content"><p>Search shows the first 10,000 results. To see the rest, narrow the search.</p></div>
</div>
<nav class="ds-pagination ds-pagination--top" aria-label="Search results pages">
<span class="ds-pagination-position">1–50 of 18,659 results</span>
<button type="button" class="ds-btn ds-btn-text" disabled><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg> <span class="ds-pagination-label">Previous</span></button>
<ol class="ds-pagination-pages">
<li><a href="?page=1" aria-current="page"><span class="is-sr-only">Page </span>1</a></li>
<li><a href="?page=2"><span class="is-sr-only">Page </span>2</a></li>
<li><a href="?page=3"><span class="is-sr-only">Page </span>3</a></li>
<li><a href="?page=4"><span class="is-sr-only">Page </span>4</a></li>
<li><a href="?page=5"><span class="is-sr-only">Page </span>5</a></li>
<li>…</li>
<li><a href="?page=374"><span class="is-sr-only">Page </span>374</a></li>
</ol>
<a class="ds-btn ds-btn-text" href="?page=2"><span class="ds-pagination-label">Next</span> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a>
</nav>
<ol class="demo-list">
<li>The first result</li>
<li>The last result on this page</li>
</ol>
<nav class="ds-pagination ds-pagination--bottom" aria-label="Search results pages, below the list">
<span class="ds-pagination-position">1–50 of 18,659 results</span>
<button type="button" class="ds-btn ds-btn-text" disabled><svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m15 18-6-6 6-6"/></svg> <span class="ds-pagination-label">Previous</span></button>
<ol class="ds-pagination-pages">
<li><a href="?page=1" aria-current="page"><span class="is-sr-only">Page </span>1</a></li>
<li><a href="?page=2"><span class="is-sr-only">Page </span>2</a></li>
<li><a href="?page=3"><span class="is-sr-only">Page </span>3</a></li>
<li><a href="?page=4"><span class="is-sr-only">Page </span>4</a></li>
<li><a href="?page=5"><span class="is-sr-only">Page </span>5</a></li>
<li>…</li>
<li><a href="?page=374"><span class="is-sr-only">Page </span>374</a></li>
</ol>
<a class="ds-btn ds-btn-text" href="?page=2"><span class="ds-pagination-label">Next</span> <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="m9 18 6-6-6-6"/></svg></a>
</nav>
</section>
</main>
- <h1>
- The page heading. The demo here uses smaller headings because it sits inside this page.
- .ds-form--compact
- The search form, on the page ground before and after a search.
- <label> with a select
- The settings for the results, such as order and results per page, as compact selects beside the other options under the search row. A link to another page, such as Advanced search, takes the end of that line.
- <section>
- The results: the heading, the notice, the two bars and the list are one region of the page, named by the heading. Inside it, the bars keep the list's own spacing.
- <h2>
- The results heading, “Results for” and the query. It gives no count: the count is in the bar below it.
- .ds-alert
- A message about the whole set of results, such as a limit on how many can be reached. It goes above the page numbers. See Single line.
- .ds-pagination--top, .ds-pagination--bottom
- The range and page numbers above and below the results, in tinted bars. See Numbered pages.
- <section aria-labelledby> for the results
- Whatever the search finds. A paper is shown as on Papers; another kind of record has its own pattern.
Accessibility essentials
- Name the form. The search form takes
role="search"and anaria-label. - Say what was found in the page title. The
<title>names the query and the number of results, so a screen reader announces both when the page loads.
Rules
- The search form stays on the page ground, before and after a search.
- A heading names the results: “Results for” and the query, with no count.
- Settings for the results go with the search, never in the pager. Choose a default for each; the reader changes it under the search row.
- An alert goes at the top of the part of the page it is about. A message about the query goes below the page heading, above the form; a message about the results goes below the results heading. See Alerts.
- The range and page numbers belong to the results. They sit in tinted bars above and below the results, under the results heading.
- Matched words are marked with
<mark>. See Search-matched words. - No results is a message, not an empty page. An info alert where the results would be says what was searched for, and the help for searching follows it.