Require title to have textual content

Rule ID:
empty-title
Category:
Accessibility
Standards:
  • WCAG 2.2 (A)
  • WCAG 2.1 (A)
  • WCAG 2.0 (A)

The <title> element is used to describe the document and is shown in the browser tab and titlebar. The content cannot be whitespace only.

WCAG (H25) and SEO requires a descriptive title and preferably unique within the site. For SEO a maximum of around 60-70 characters is recommended.

Each title should make sense on its own and properly describe the document. Avoid keyword stuffing.

See also WCAG G88: Providing descriptive titles.

Rule details

Examples of incorrect code for this rule:

<head>
    <title></title>
</head>
error: <title> cannot be empty, must have text content (empty-title) at inline:2:6:
  1 | <head>
> 2 |     <title></title>
    |      ^^^^^
  3 | </head>


1 error found.

Examples of correct code for this rule:

<head>
    <title>Lorem ipsum</title>
</head>

Whitespace

Text with only whitespace is also considered empty.

<head>
    <title> </title>
</head>
error: <title> cannot be empty, must have text content (empty-title) at inline:2:6:
  1 | <head>
> 2 |     <title> </title>
    |      ^^^^^
  3 | </head>


1 error found.