Extensible Hypertext Markup Language

What is xhtml?

XHTML is the cleaner and stricter version of HTML. It was started in 2000 with version XHTML1.0 . XHTML 1.1 comes into existence in 2001. Its very much similar to HTML 4.0.

Doctype of XHTML 1.0

Way to write Doctype of XHTML 1.0



<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
		
		

Doctype of XHTML 1.1

Way to write Doctype of XHTML 1.1


						
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

		

Difference in XHTML

XHTML is different from HTML 4.0 in many ways. Like,

  • DOCTYPE declaration is must in an XHTML page which is written at the top of the document.
  • XHTML tags and attributes should be written in lower case only.
  • Closing tags are compulsory.
  • Values of attributes must be quoted.
  • All the tags should be properly nested.
  • All Non-pair tags should be closed with slash. e.g( < img src=" " /> , < br /> )
  • Use Id attribute instead on name in XHTML.
  • Value of attribute is must.

Except last three, all rules are followed in HTML5


HTML4 Vs XHTML Vs HTML5

HTML4 XHTML HTML5
<DIV></DIV> <div></div> Both allowed, but lowercase preffered
<img src="" alt="" > <img src="" alt="" /> Both allowed, but <img src="" alt=""> is preffered
<br> <br /> <br> is preffered
<img src="" alt="" width=200 > <img src="" alt="" width="200" /> <img src="" alt="" width="200">
<input type="text" disabled > <input type="text" disabled="disabled" /> <input type="text" disabled>