EXtensible HyperText Markup Language is known as XHTML. The language is a hybrid of HTML and XML. Although XHTML and HTML are almost identical, HTML is less restrictive. The definition of HTML as an XML application is XHTML. The majority of popular browsers support it. It is essential to write your code correctly, even if XHTML and HTML are almost identical in terms of syntax and case sensitivity. In contrast to HTML, which needs a flexible HTML-specific parser, XHTML texts are well-formed and may be processed using conventional XML parsers.
In order to improve HTML's extensibility and compatibility with other data formats, XHTML was created.
The development of XHTML was motivated by two key factors:
It provides a stronger standard for developing online pages, hence reducing browser incompatibilities. As a result, it works with all popular browsers.
It provides a standard that may be applied unchanged to a wide range of devices.
Although HTML is mostly used to construct web pages, we can observe that a large number of them utilise "deficient" HTML (not following the HTML rule).
In most browsers, this HTML code functions well (even if it does not follow the HTML rules).
XHTML documents consist of three sections, listed as follows:
DOCTYPE
DOCTYPE is used to declare a DTD.
Head
The title and other specific data are presented in the Head segment.
Body
The webpage content is shown in the body. There are various tags in it.
A Document Type Definition(DTD) must be provided in order to create an XHTML webpage. The three distinct DTD types are
Transitional DTD – It is compatible with older browsers that do not support CSS.
Strict DTD – It is used when an XHTML page simply contains markup language.
Frameset DTD – When XHTML pages have frames, it is utilised.
For Example,
<html>
<head>
<title>Hello World</title>
<body>
<h1>Using HTML
<p> This program is written using HTML coding to say hello to everyone in this world.
</body>
Output:
Hello World
Using HTML
This program is written using HTML coding to say hello to everyone in this world.
Despite working, the HTML code above does not follow the HTML standard. There are several browser technologies available today. Some browsers operate on PCs, while others operate on smartphones or other portable devices. The fundamental problem with improper HTML is that smaller devices cannot understand it.
The following are XHTML's features:
It is extensible.
In comparison to other codes, it is more versatile.
All browsers are compatible with it.
It handles errors with a much stricter approach.