Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

How is xhtml syntax similar to html syntax?


Asked by Rhea Knox on Dec 12, 2021 HTML



XHTML syntax is very similar to HTML syntax and almost all the valid HTML elements are valid in XHTML as well. But when you write an XHTML document, you need to pay a bit extra attention to make your HTML document compliant to XHTML.
Consequently,
XHTML uses an XML syntax, while HTML uses a pseudo- SGML syntax (officially SGML for HTML 4 and under, but never in practice, and standardised away from SGML in HTML5). Because the expressible contents of the DOM in syntax are slightly different, there are some changes in actual behavior between the two models.
Keeping this in consideration, There are certain syntax rules in XHTML that must be followed. XHTML syntax rules are not the same as the tag rules discussed in the differences between HTML and XHTML tutorial, though some of the information from that tutorial is repeated here. The syntax rules presented in this tutorial mostly revolve around tag attributes.
Thereof,
You must remember the following important points while writing a new XHTML document or converting existing HTML document into XHTML document: All documents must have a DOCTYPE. All tags must be in lower case. All documents must be properly formed. All tags must be closed. All attributes must be added properly. The name attribute has changed.
Also,
In the year 2000, XHTML’s first version, also called XHTML 1.0, was launched by the World Wide Web. It came up with modern syntax rules and tags. It was a blend of XML and HTML. XHTML 1.0 was almost similar to HTML 4.0 and there were three document types (transitional, frameset, and strict) under which developers categorized them.