HTML Guides for favicon
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.
MIME types (also called media types) follow a strict type/subtype structure as defined by IETF standards. For example, image/png has the type image and the subtype png. The value "favicon" doesn't follow this format — it has no slash and no subtype — so the validator reports "Subtype missing." This is a common mistake that happens when developers confuse the purpose of the icon (a favicon) with the format of the file (an image in a specific encoding).
While most browsers are forgiving and will still display the favicon even with an invalid type value, using incorrect MIME types can cause issues. Some browsers or tools may ignore the <link> element entirely if the type doesn't match a recognized format. It also hurts standards compliance and makes your HTML less predictable across different environments.
The correct MIME type depends on the file format of your favicon:
.icofiles:image/x-icon(orimage/vnd.microsoft.icon).pngfiles:image/png.svgfiles:image/svg+xml.giffiles:image/gif
It's also worth noting that the type attribute on <link rel="icon"> is entirely optional. If omitted, the browser will determine the file type from the server's Content-Type header or by inspecting the file itself. Removing it is a perfectly valid fix.
Examples
❌ Invalid: using "favicon" as the type
<link rel="icon" href="/favicon.png" type="favicon">
The value "favicon" is not a valid MIME type, triggering the validation error.
✅ Fixed: using the correct MIME type for a PNG favicon
<link rel="icon" href="/favicon.png" type="image/png">
✅ Fixed: using the correct MIME type for an ICO favicon
<link rel="icon" href="/favicon.ico" type="image/x-icon">
✅ Fixed: using the correct MIME type for an SVG favicon
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
✅ Fixed: omitting the type attribute entirely
<link rel="icon" href="/favicon.png">
Since the type attribute is optional for <link rel="icon">, removing it avoids the error and lets the browser detect the format automatically. This is often the simplest and most maintainable approach.
A data: URI in the href attribute of a <link> element can't contain literal spaces, so an inline SVG icon in that URI needs every space written as %20.
The data: scheme, defined in RFC 2397, puts the file itself in the attribute value. The data after the comma may only contain URL characters, and a space isn't one of them. The ta: in the message is the end of data:: the validator quotes the scheme, not the position of the space, so the space can be anywhere in the value. When the value runs past about a thousand characters, the validator leaves it out of the message, which then reads Bad value for attribute “href” with nothing between the two words.
The usual cause is a favicon written as inline SVG, as in <link rel="icon" href="data:image/svg+xml,...">. SVG markup needs a space between the element name and each attribute, and encoding only the angle brackets as %3C and %3E leaves those spaces in place. Spaces inside attribute values, such as viewBox='0 0 16 16' or the numbers in a path's d attribute, trigger it too.
Browsers usually show the icon anyway, but the value is still an invalid URL. Replace every space with %20, or base64-encode the SVG and add ;base64 before the comma. In JavaScript, encodeURIComponent() converts the spaces along with the other reserved characters. If the icon is large or used on many pages, save it as a .svg file and point href at that file, which also lets the browser cache it.
Invalid example
<link rel="icon" href="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='8' r='8' fill='teal'/%3E%3C/svg%3E">
Valid example
<link rel="icon" href="/favicon.svg" type="image/svg+xml">
Validate at scale.
Ship accessible websites, faster.
Automated HTML & accessibility validation for large sites. Check thousands of pages against WCAG guidelines and W3C standards in minutes, not days.
1K Weekly
1,000 monthly checks. Cancel anytime.
Get 1K Weekly →Join teams across 40+ countries