XHTML and HTML Difference
October 24th, 2005
Lots of my juniors ask me why W3C developed XHTML, when we have pretty good HTMl 4.01?
Though HTML 4.01 is good enough, but it lacks some basic standard. XHTML is just an improved version of HTML which inherits some basic features of XML (Extensible Markup Language).
As per W3C.org
Document developers and user agent designers are constantly discovering new ways to express their ideas through new markup. In XML, it is relatively easy to introduce new elements or additional element attributes. The XHTML family is designed to accommodate these extensions through XHTML modules and techniques for developing new XHTML-conforming modules (described in the XHTML Modularization specification). These modules will permit the combination of existing and new feature sets when developing content and when designing new user agents.
Alternate ways of accessing the Internet are constantly being introduced. The XHTML family is designed with general user agent interoperability in mind. Through a new user agent and document profiling mechanism, servers, proxies, and user agents will be able to perform best effort content transformation. Ultimately, it will be possible to develop XHTML-conforming content that is usable by any XHTML-conforming user agent.
If you know HTML pretty good, it will take only 30 mins for you to be master of XHTML. There are only 6-7 things which you have to keep in mind to switch from HTML to XHTML.
The basic difference between XHTML and HTML are, in XHTML
Elements should be properly nested.
If you using multiple element nested in each other, then make sure they are properly nested. For example, <p>Hello World! I am from <strong>India</p></strong> is wrong, it should be <p>Hello World! I am from <strong>India</strong></p>
All elements and attributes should be in lowercase. XHTML is based on XML which is a case-sensitive language is <UL> is invalid in XHTML
All elements required end tag or in other words they should be closed. For example, <p>Hello World!</p>. Even if it’s an Empty element like <br> or <hr>, it should be closed like <br /> or <hr />
Note: To make your XHTML compatible with today’s browser, add an extra space before “/” in empty elements. Like <hr />
All attributes should be quoted. For example, <td rowspan=”3”>
XML does not support attribute minimization, so does XHTML. In XHTML attribute values must be written in full. For example: <dl compact> is wrong, it should be <dl compact=”compact”>.
Entry Filed under: Web 2.0
Leave a Comment
You must be logged in to post a comment.
Trackback this post | Subscribe to the comments via RSS Feed