HTML Guides for open graph protocol
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.
In older XHTML documents, XML namespaces were declared using the xmlns attribute with a prefix, such as xmlns:og="http://ogp.me/ns#". While this syntax was valid in XHTML, HTML5 does not support custom XML namespace declarations on the <html> element. The W3C validator will flag any xmlns:* prefixed attribute (like xmlns:og, xmlns:fb, etc.) as invalid because HTML5 has a strictly defined set of allowed attributes on the <html> element.
The Open Graph Protocol, originally developed by Facebook, allows web pages to become rich objects in a social graph. Major platforms like Facebook, Twitter, LinkedIn, and others rely on Open Graph <meta> tags to generate link previews. The official Open Graph Protocol specification recommends using the prefix attribute on the <html> element instead of the xmlns:og namespace declaration.
The prefix attribute is part of the RDFa specification and is recognized by HTML5 as a valid way to declare vocabulary prefixes. By switching to prefix="og: https://ogp.me/ns#", you maintain full Open Graph functionality while keeping your HTML valid.
How to fix it
- Locate the
<html>tag in your document. - Remove any
xmlns:og(or similarxmlns:*) attributes. - Add or update the
prefixattribute with the appropriate namespace declaration.
If you use multiple prefixes (e.g., Open Graph and Facebook-specific tags), you can combine them in a single prefix attribute, separated by a space.
Examples
❌ Invalid: Using xmlns:og (XHTML-style namespace)
<!DOCTYPE html>
<htmllang="en"xmlns:og="http://ogp.me/ns#">
<head>
<title>My Page</title>
<metaproperty="og:title"content="My Page Title"/>
<metaproperty="og:type"content="website"/>
<metaproperty="og:url"content="https://example.com/"/>
<metaproperty="og:image"content="https://example.com/image.jpg"/>
</head>
<body>
<p>Page content here.</p>
</body>
</html>
This triggers the validator error: Attribute "xmlns:og" not allowed here.
✅ Valid: Using the prefix attribute
<!DOCTYPE html>
<htmllang="en"prefix="og: https://ogp.me/ns#">
<head>
<title>My Page</title>
<metaproperty="og:title"content="My Page Title"/>
<metaproperty="og:type"content="website"/>
<metaproperty="og:url"content="https://example.com/"/>
<metaproperty="og:image"content="https://example.com/image.jpg"/>
</head>
<body>
<p>Page content here.</p>
</body>
</html>
✅ Valid: Multiple prefixes (Open Graph and Facebook)
If you also use Facebook-specific meta tags (like fb:app_id), declare both prefixes:
<!DOCTYPE html>
<htmllang="en"prefix="og: https://ogp.me/ns# fb: https://ogp.me/ns/fb#">
<head>
<title>The Rock (1996)</title>
<metaproperty="fb:app_id"content="123456789"/>
<metaproperty="og:title"content="The Rock"/>
<metaproperty="og:type"content="video.movie"/>
<metaproperty="og:url"content="https://www.imdb.com/title/tt0117500/"/>
<metaproperty="og:image"content="https://ia.media-imdb.com/images/rock.jpg"/>
</head>
<body>
<p>Page content here.</p>
</body>
</html>
❌ Invalid: Multiple xmlns declarations
This older pattern with multiple namespace declarations is equally invalid in HTML5:
<htmlxmlns:og="http://ogp.me/ns#"xmlns:fb="http://ogp.me/ns/fb#">
Replace it with the single prefix attribute as shown in the examples above.
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.
Pro Trial
Full Pro access. Cancel anytime.
Start Pro Trial →Join teams across 40+ countries