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


Paul Carter
Paul Carter
12,543 Points

DocType - HTML vs XHTML

Hi everyone - thanks very much for your help with my other questions!

I'm back with a new one.

So from HTML & CSS: Design and Build Web Sites (I recommend this as a very handy reference guide) I learnt that there are a few versions of HTML - XHTML 1.0 is one of these.

Could anyone tell me, or point me in the direction of a resource (preferably free) which explains these different versions of HTML.

In particular I am keen on reading about XHTML 1.0.

Also, is it possible to update a website to a newer HTML? Absolute newb question here but is it just a case of changing the <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> tag to a <!DOCTYPE html> tag? If not, why not?

Thanks for your help in advance. I'm happy to clarify if anything doesn't make sense!


3 Answers

James Barnett
James Barnett
39,199 Points

+1 for the HTML & CSS: Design and Build Websites it's the nicest looking reference book I've ever seen.

XHTML is dead, development was ended by the W3C back in 2009. However HTML5 is backward compatible with XHTML so if all you change is the doctype you will be set.

The syntax of HTML5 is actually a lot looser you can do all sorts of things that may or may not be actually be a good idea and still end up with valid HTML5 markup.

Here's a great blog post on suggested HTML5 syntax

Hi Paul,

Here are a couple of good reads on the subject:

Keep in mind though, that article from A List Apart is over 10-years old now. Basically the versions of HTML have gone HTML1, HTML2, HTML3, HTML4, XHTML1, HTML5.

For a while XML (eXtensible Markup Language) was thought to be a huge deal. It is, but not quite as huge as people thought it was going to be. HTML is a fairly loose language. Back in the day, you could write really sloppy HTML code (ex: <p><b></p></b> - overlapping sequence) and it would interpret it just fine without a problem. No black-lash from Google (they didn't exist), etc.

XML is quite different than HTML in some respects. XML needs to be strictly formatted to the DTD (Document-Type Deceleration). In order to ease that transition from HTML to XML, they created XHTML as a kind of middle-ground.

For the transition, lots of people were having to make edits to their code. For example, changing a <br> tag to <br /> because in XML every opening tag needs to have a closing tag. A tag like a <br> HAS no closing tag (same with <meta> tags) so they self-terminate with a forward-slash at the end. Also, some attributes needed to be removed.

For example, we would remove a <body> tag's margins with CSS like so: body { margin:0; padding:0; }

But back then (in the 90's) we would use attributes: <body marginwidth="0" marginheight="0">

Needless to say, simply changing the !Doctype won't up-date your HTML on the page. It just tells the browser how it should expect the HTML that follows to be written for interpretation.

Wikipedia has a decent entry on XHTML

Hope this helps. Cheers.

James Barnett
James Barnett
39,199 Points

Eric - A better article on xhtml then the outdated a list apart article would be this explaination in webcomic form over on smashing