A person arriving at a web page sees a headline, a photograph, a price and a button. A search engine's crawler arriving at the same address receives a stream of text: tags, attributes, scripts and, somewhere among them, the words.

Whether that page will ever be shown to a searcher depends on what the crawler makes of the stream. The process has four stages, and a page can fail at each.

Stage one: discovery and crawling

A search engine finds pages mainly by following links. Its crawler, a program that fetches pages automatically, starts from addresses it knows, downloads them, extracts every link and adds the new addresses to a queue. It also reads sitemaps, which are files listing a site's pages.

The first failure is to be unreachable. A page that no other page links to may never be found. Content that appears only after a visitor types into a search box or chooses from a menu built entirely in script may have no address a crawler can follow. A crawler reliably follows ordinary links: an anchor element with an address in it. It does not click buttons.

Before fetching, a well-behaved crawler reads a file called robots.txt at the root of the site, which says what it may and may not request. A single mistaken line there can remove a whole site from search. It happens regularly, most often when a setting meant for a test version is carried over to the live one.

Crawlers also ration their effort. A large site with many near-duplicate addresses, generated by filters and tracking parameters, can exhaust its allowance on pages that do not matter.

Stage two: rendering

Many modern sites send almost empty HTML and build the page in the browser with JavaScript. A crawler that reads only the initial HTML sees nothing.

The major search engines now run the JavaScript, using a headless version of a real browser. This happens as a separate step, however, and may be delayed. It can time out, or fail if a script depends on something the crawler blocks. Other crawlers, including many of those gathering text for AI systems and those that build link previews for social networks, do not run scripts at all.

The safest arrangement is for the content to be present in the HTML the server sends. Rendering on the server, or generating pages ahead of time, makes the page robust for every kind of reader.

Stage three: understanding

Now the engine has the rendered document and must work out what it is about. This is where the choice of HTML elements matters.

Compare two ways of marking up the same heading.

<div class="big-bold-text">Opening hours</div>

<h2>Opening hours</h2>

They can be styled to look identical. To a machine the first is an anonymous box containing two words. The second is a second-level heading, a statement about the structure of the page.

HTML has elements that carry meaning of this kind: headings in six levels, paragraphs, lists, tables with header cells, navigation, the main content, articles, figures with captions, time and address. Using them is called semantic markup. A parser can build an outline of the page from them: this is the main topic, these are the subtopics, this block is navigation and can be given less weight.

Some elements matter especially.

The title element. It is the strongest single statement of what the page is, and usually becomes the link shown in results.

The meta description. Not a ranking factor, by the engines' own account, but often used as the snippet under the link.

Headings. One first-level heading that states the subject, with the rest in logical order.

Link text. The words in a link describe the page it leads to. "Read our returns policy" tells both the reader and the engine something. "Click here" tells them nothing.

Alternative text on images. Search engines have become good at analysing images, but the alt attribute is still the clearest statement of what a picture shows.

The language attribute and canonical link. The first says what language the page is in. The second says which address is the preferred one when the same content is available at several.

Structured data

Beyond HTML's own vocabulary, a page can describe itself in a formal way using a shared vocabulary maintained jointly by the main search engines since 2011. The description is usually embedded as a block of JSON.

It states facts outright: this page is about a product, with this name, this price, this currency, in stock, with this average rating from this many reviews. Or a recipe with these ingredients and this cooking time. Or an event on this date at this place.

The engine no longer has to infer these from the layout. In return it may display them directly, as the stars, prices, cooking times and dates that appear in some results. It is also how many voice assistants and AI systems extract specific facts.

Structured data must match what is visibly on the page. Marking up reviews that do not exist is treated as spam.

Stage four: indexing and ranking

The engine stores what it has understood in an index, organised so that pages matching a query can be found in milliseconds. Not every crawled page is indexed. Duplicates, thin pages and those marked "noindex" are left out.

Ranking is a separate and much larger subject. The engines say they use hundreds of signals, and they do not publish the details. Broadly, these concern how well the content matches what the searcher wants, how trustworthy the page and site appear, including who links to them, and how usable the page is. Modern systems use language models to match meaning, not just words, so repeating a phrase many times no longer helps and can hurt.

All of that sits on top of the first three stages. A page that is never crawled, or that renders empty, or whose meaning cannot be made out, will not rank whatever its quality.

One piece of work, two audiences

The requirements above are almost the same as the requirements for accessibility.

A screen reader, used by people who are blind or have low vision, works from the same structure a crawler does. Its users navigate by jumping between headings, listing the links on a page, moving through landmarks such as navigation and main content, and hearing the alternative text of images. Surveys of screen-reader users consistently find that headings are the most common way of finding information on a page.

So the markup choices line up:

Practice For search engines For assistive technology
Real headings in order Outline of the topic Navigation by heading
Descriptive link text Describes the target Makes sense in a list of links
Alt text Describes the image Read aloud in place of the image
Landmarks Separates content from chrome Jump straight to main content
Content in the HTML Reliable indexing Works when scripts fail
Proper buttons and links Links can be followed Keyboard operable
Table header cells Data can be extracted Cells announced with their headers

It has been said that a search engine is the most influential blind user a site will ever have. The comparison is imperfect, since crawlers do not operate forms or menus as people do, but the overlap is large, and work done for one audience serves the other.

Checking what was seen

There is no need to guess.

  • The search engines provide free consoles in which a site owner can see which pages are indexed, which were excluded and why, and can inspect any address to see the rendered HTML as the crawler saw it.
  • Viewing the page source, as distinct from the inspector, shows what arrives before any script runs.
  • Turning off JavaScript in the browser and reloading shows what a non-rendering crawler gets.
  • Free validators check structured data for errors.
  • A screen reader, built into every major operating system, shows what the structure sounds like. Ten minutes of navigating your own page by headings alone is instructive.

A short checklist

  1. Every page can be reached by an ordinary link, and appears in the sitemap.
  2. The robots file and "noindex" tags block only what you intend.
  3. The main content is in the HTML the server sends.
  4. A unique, descriptive title on every page.
  5. One first-level heading, and a sensible hierarchy beneath it.
  6. Elements used for what they mean. Buttons are buttons and links are links.
  7. Alt text on meaningful images.
  8. Structured data where the content fits a recognised type.
  9. A canonical address for duplicated content.
  10. Check the result in the search console, with scripts off, and with a screen reader.

None of this is advanced. It is mostly a matter of using HTML as it was designed, which serves crawlers and screen readers at once.