Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Lee Jay Robertson
Lee Jay Robertson
1,598 Points

Html email doctype xmlns which one?

I have taken the plunge and have started building me own email. I have noticed a difference with the xmlns used.

Some use the:

<html xmlns="http://www.w3.org/1999/xhtml">

and others seem to be adopting this:

<html xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraph.org/schema/">

Primarily what is the difference? Is there benefits / reasons for using the fb and schema? Do I need to do anything different in the rest of the html file?

Many Thanks Lee

1 Answer

xmlns stands for XML Namespaces

They are used in XML and XHTML so that you can have elements with the same name for different things.

The first one you shared is the default namespace for XHTML. That tells the browser (or in this case, the email client) that the HTML is actually XHTML.

The fb namespace is for Facebook to include their own 'FBML' or Facebook Markup Language, without breaking standard XHTML code.

The og namespace is for the 'Open Graph Protocol', which is used to indicate to websites and applications how to display information about your website/page, mostly when sharing via social media/networking. I think Facebook might have started it also.

You'd only need the fb and og namespaces if you had Facebook FBML code in your email's XHTML or if the same code will be used to display the email on the web (in a browser) and you want people to be able to share it on social networks.