HTML (HyperText Markup Language) is the code that describes the content of a web page. It wraps each piece of content in an element that says what it is:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Trail running shoes for muddy paths</title>
<meta name="description" content="How to pick a trail shoe that grips in mud.">
</head>
<body>
<h1>Trail running shoes for muddy paths</h1>
<p>Deep lugs grip better in mud. <a href="/guides/fit">Check the fit</a> first.</p>
<img src="shoe.jpg" alt="Trail shoe with deep lugs on the sole">
</body>
</html>
The parts in angle brackets are HTML tags. The settings inside a tag, like href or alt, are attributes. The <head> holds information about the page; the <body> holds what readers see.
HTML is a markup language, not a programming language: it describes content but doesn't calculate or decide anything. Pages usually combine three languages. HTML says what things are, CSS says how they look, and JavaScript makes them do things.
How browsers and search engines read it
A browser turns the HTML into a tree of objects, the Document Object Model, then draws the page from it. Browsers are forgiving: they repair missing end tags and other mistakes rather than refuse the page.
Google works from HTML too, specifically the rendered HTML: the page as it stands after JavaScript has run. If your content only appears after JavaScript runs, check that it's there in the rendered version, because Google can't index what isn't. Google Search Central The URL Inspection tool in Search Console shows the HTML Google rendered.
The parts of HTML that matter for SEO
Most of a page's HTML is for the browser. These parts are the ones search engines read most closely:
| Element | What it does in search |
|---|---|
<title> |
The first source Google lists for the page's title link in results. See meta title. |
<meta name="description"> |
May become the snippet under the title. See meta description. |
<h1> to <h6> |
Headings structure the page; Google also uses them for title links. See heading tags. |
<a href="..."> |
Links Google can follow. Google generally only crawls links written as an <a> element with an href, not a script click handler. |
<img alt="..."> |
The alt attribute describes images, and acts as anchor text when an image is a link. |
<link rel="canonical"> |
Names your preferred URL among duplicates. See canonical tag. |
<meta name="robots"> |
Controls indexing, for example with noindex. See meta tags. |
Using elements for their meaning, such as <nav> for navigation, <button> for buttons and lists for lists, is called semantic HTML. It helps screen readers most of all; for search, the elements in the table matter more.
Does HTML have to be valid?
Not perfectly. Google points out that the web in general isn't valid HTML, so it rarely depends on the finer meanings in the HTML specification. Heading order, for example, doesn't matter to Google Search, though it matters to screen reader users. Google Search Central
The <head> is the exception worth guarding. Google asks for a valid head so it can read your meta tags, and it accepts a canonical tag only there; a stray element in the head can cost you both. An HTML validator finds these errors quickly.
Which version is current?
There's one HTML today: the HTML Living Standard, maintained by the WHATWG and updated continuously rather than released in numbered versions. Since a 2019 agreement, the W3C and WHATWG work on this single version. WHATWG
"HTML5" is still the everyday name for modern HTML, and the standard itself answers "Is this HTML5?" with yes. Start every page with <!DOCTYPE html>; older doctypes with version numbers are no longer needed.
HTML began at CERN around 1990, then passed through the IETF and the W3C before the Living Standard. For your pages, the history matters less than this: browsers support the current standard, and you can use it.
How to see a page's HTML
- View page source, in the right-click menu of desktop browsers, shows the HTML the server sent.
- Developer tools (right-click, then Inspect) show the current DOM, after JavaScript has changed it.
If the two differ a lot, your page builds its content with JavaScript. That's fine, as long as the rendered version contains what you want indexed.