HTML XHTML
- XHTML tands for "Extensible Hypertext Markup Language."
- XHTML is markup language used to create webpages.
- It is similar to HTML but uses a more strict XML-based syntax.
- The first version of XHTML (1.0) was standardized in 2000.
Why XHTML?
As HTML evolved over the first few decades of the web, browsers became increasingly lenient in how they parsed webpage source code. The result was that websites were rendered inconsistently between browsers. One of the main goals of XHTML was to ensure webpages looked the same across multiple browsers.
Since XHTML is based on XML rather than HTML, webpages coded in XHTML must conform to a strict XML syntax. A webpage that uses the "XHTML Strict" doctype (DTD) cannot contain any errors or invalid tags, leaving no ambiguity for the web browser. However, most XHTML sites used the "XHTML Transitional" doctype, which does not require perfect syntax and even allows HTML 4.01 tags.
The XHTML documents contains three parts, which are discussed below:
- DOCTYPE: It is used to declare a DTD
- head: The head section is used to declare the title and other attributes.
- body: The body tag contains the content of web pages. It consists many tags.
Bad HTML
<html>
<head>
<title>This is a bad HTML</title>
<BODY>
<h1>This is a bad HTML heading.
<p>This is a bad HTML paragrapg.
</body>
</html>
Usually HTML code works fine in most of the browsers even if the codes do nort follow the HTML rules.
Good HTML
<!DOCTYPE html>
<html>
<head>
<title>This is a good HTML</title>
</head>
<body>
<h1>This is a good HTML heading.</h1>
<p>This is a good HTML paragrapg.</p>
</body>
</html>
- XML is a markup language where documents must be marked up correctly.
- XHTML was developed by combining the strengths of HTML and XML.
- XHTML is HTML redesigned as XML.