Did you find this useful?
Socialize it today.


HTML vs XHTML

Monday, January 30, 2012

HTML has been around for quite some time now. The first version of HTML was not assigned a version number, it was just called "HTML" and was used till about 1995. In 1995, the Internet Engineering Task Force standardized HTML and assigned it a version and called it "HTML 2.0". The standardization was important as to ensure that as new web browsers were being developed, they would all follow the same standard so that they would all properly interpret the same HTML code. By 1997, the World Wide Web Consortium, also known as W3C, presented the next version of HTML, known as HTML 3.2. Shortly after, additional changes were made to the standard and it was followed by HTML 4.0 in 1998. Once year later, HTML 4.01 was standardized in 1999. Then the W3C announced that it would not be creating new versions of HTML, and would begin to focus on extensible HTML or XHTML. The recommendation was for web designers use HTML 4.01 for their HTML documents. XHTML is a stricter forum of HTML. At this point, the W3C continued to focus on XHTML 1.0, and XHTML recommendations began in the year 2000 and onward. The problem was that web designers did not embrace the fact that a new stricter form of HTML was to be used. By this time, there were millions of web pages that were written in a less strict version. In 2004, the Web Hypertext Application Technology Working Group (WHATWG) began working on a new version of HTML that is not as strict as XHTML called HTML5. At this time, HTML5 is not a standard, and all of the elements are not supported across all of the major browsers.

HTML vs XHTML

Whether you choose to write your markup in HTML or XHTML may depend on your current experience with this language. There are a number of differences between XHTML and HTML, but what you need to know at this time is that XHTML is HTML 4.01 written as extensible markup language (XML). For the most part, if you write XHTML, all your attributes will be quoted, your tags are in lowercase and closed. HTML is not as strict as XHTML because you can leave quotes off attributes, leave tags opened. So, once you learn HTML, if you follow some of the XHTML guidelines, you will be writing in XHTML. When choosing what version of HTML you should write, most designers base their decision on web browser support. The most common version of HTML is HTML 4.01 Transitional. It is supported in all modern browsers and provides most of the tags and features designers expect HTML to provide.

Why use XHTML?

XHTML is much clearer on the beginning and end of elements. This makes it much cleaner and easier for styles and events to be integrated. Most importantly, XHTML integrates very well into other programming languages because it is actually XML. Some browsers respond more reliably to XHTML so pages render consistently across browsers and platforms. XHTML 1.x is the first version of XHTML to be released from the W3C.

Which version of HTML should I choose?

There are several versions of HTML still widely used by web developers

  • Quirks
  • HTML 3.2
  • HTML 4.0
  • HTML 4.01
  • HTML 5
  • XHTML 1.0

The version of HTML is determined by the DOCTYPE that you assign to the web page (more details about DOCTYPE later). When a DOCTYPE is not declared, the version is considered as "Quirks" mode. Since the browser rendering the page doesn't know which version of HTML it is reading, the browser will do its best to interpret the code and display the information properly. Not declaring a DOCTYPE can result in different browsers displaying the information slightly different. At this time, HTML 4.01 is the most recent version of the standard, and it is the most widely accepted by all modern browsers. With regard to HTML5, most browsers only support it partially, meaning not all HTML5 elements are understood by all browsers. It is recommended to proceed with setting up your new website declaring it as an HTML5 document, but do not use HTML5 specific elements until all of the expected browsers being used to access your site support the new elements. When it comes to XHTML, there are two versions, 1.0 and 2.0. XHTML 2.0 is new and is not supported by modern browsers. So, if you are going with XHTML, stick with XHTML 1.0 for now.

Please help us spread the word by socializing it today!

email contact us

Did you find something wrong with the information on this page? Please take a moment to report it to us so that we can continue to improve the quality of the information on this site. Click here to report an issue with this page.



Recommended Books & Training Resources

HTML CSS: The Complete Reference HTML CSS and JavaScript Editor Creating Web Pages Simplified