HTML Guides for non empty
Learn how to identify and fix common HTML validation errors flagged by the W3C Validator — so your pages are standards-compliant and render correctly across every browser. Also check our Accessibility Guides.
The <option> element represents a choice within a <select> dropdown, a <datalist>, or an <optgroup>. According to the HTML specification, every option must have a name — the text that is displayed to the user. This name can come from one of two sources: the text content between the opening <option> and closing </option> tags, or the label attribute on the element. If neither is provided, the option renders as a blank entry in the dropdown, which creates several problems.
From an accessibility standpoint, screen readers rely on the option’s label to announce each choice to the user. An empty, unlabeled option gives assistive technology nothing meaningful to read, making the control unusable for some users. From a usability perspective, sighted users see a blank line in the dropdown and have no idea what it represents. And from a standards compliance perspective, the HTML specification explicitly requires that an <option> without a label attribute must not have empty content.
Note that the value attribute is separate from the display text. The value is what gets submitted with the form, while the label/text content is what the user sees. Setting a value does not satisfy the requirement for visible text.
How to fix it
You have two options:
- Add text content inside the <option> element (the most common and recommended approach).
- Add a label attribute to the <option> element. When present, the label attribute takes precedence over the text content for display purposes in many browsers.
If you intend for an option to serve as a placeholder (e.g., “Choose one…”), make sure it still has visible text content.
Examples
❌ Empty option without a label
This triggers the validation error because the <option> elements have no text content and no label attribute:
<select name="size">
<option value=""></option>
<option value="s"></option>
<option value="m"></option>
<option value="l"></option>
</select>
✅ Fix: Add text content inside each option
<select name="size">
<option value="">Choose a size</option>
<option value="s">Small</option>
<option value="m">Medium</option>
<option value="l">Large</option>
</select>
✅ Fix: Use the label attribute
The label attribute provides the display text. The element content can then be empty or differ from the label:
<select name="size">
<option value="" label="Choose a size"></option>
<option value="s" label="Small"></option>
<option value="m" label="Medium"></option>
<option value="l" label="Large"></option>
</select>
✅ Mixing both approaches
You can use text content for some options and the label attribute for others. You can even use both on the same element — in that case, the label attribute typically takes precedence for display:
<select name="size">
<option value="">Choose a size</option>
<option value="s">Small</option>
<option value="m" label="Medium">Medium (M)</option>
<option value="l" label="Large">Large (L)</option>
</select>
❌ Common mistake: Assuming value counts as a label
This is still invalid because value is not displayed to the user:
<select name="color">
<option value="red"></option>
</select>
✅ Corrected
<select name="color">
<option value="red">Red</option>
</select>
In almost all cases, placing readable text directly inside the <option> tags is the simplest and most compatible approach. Reserve the label attribute for situations where you need the displayed text to differ from the element’s content.
The HTML specification requires every document to have a <title> element with at least one non-whitespace character. The title serves as the primary label for the page — it appears in the browser tab, in bookmarks, in search engine results, and is announced by screen readers when a user navigates to the page. An empty title leaves users with no way to identify or distinguish the page, which is especially problematic for accessibility. Screen reader users rely on the document title to understand what page they’ve landed on, and an empty title provides no context at all.
Browsers may attempt to display something (such as the URL) when the title is missing or empty, but this fallback is inconsistent and often produces a poor user experience. Search engines also depend on the <title> element for indexing and displaying results, so an empty title can negatively affect discoverability.
This error commonly occurs when templates or boilerplate code include a <title> tag as a placeholder that never gets filled in, or when content management systems fail to inject a title value into the template.
How to fix it
Add descriptive, concise text inside the <title> element that accurately reflects the content of the page. A good title is typically 20–70 characters long and specific enough to distinguish the page from other pages on the same site.
- Every page should have a unique title relevant to its content.
- Avoid generic titles like “Untitled” or “Page” — be specific.
- For multi-page sites, consider a format like “Page Name - Site Name”.
Examples
❌ Empty title element
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
</head>
<body>
<p>Welcome to our website.</p>
</body>
</html>
This triggers the error because the <title> element contains no text.
❌ Title with only whitespace
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title> </title>
</head>
<body>
<p>Welcome to our website.</p>
</body>
</html>
This also triggers the error. Whitespace-only content is treated as empty.
✅ Title with descriptive text
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Getting Started - Automated Website Validator</title>
</head>
<body>
<p>Welcome to our website.</p>
</body>
</html>
The <title> element now contains meaningful text that identifies both the page and the site, making it accessible, SEO-friendly, and standards-compliant.
Ready to validate your sites?
Start your free trial today.