HTML & XHTML

Extensible Hypertext Markup Language (XHTML) is part of the family of XML markup languages; and is mainly created to enable the code to run on browsers with limited capbilities, such as mobile phones and other wireless devices.

The syntex of XHTML is almost similar to that of HTML

  • XHTML is almost identical to HTML
  • XHTML is stricter than HTML
  • XHTML is HTML defined as an XML application
  • XHTML is supported by all major browsers

Versions of XHTML

XHTML 1.0 Strict — XHTML 1.0 Strict is the XML equivalent to strict HTML 4.01, and includes elements and attributes that have not been marked deprecated in the HTML 4.01 specification.

XHTML 1.0 Transitional — XHTML 1.0 Transitional is the XML equivalent of HTML 4.01 Transitional, and includes the presentational elements (such as center, font and strike) excluded from the strict version.

XHTML 1.0 Frameset — XHTML 1.0 Frameset is the XML equivalent of HTML 4.01 Frameset, and allows for the definition of frameset documents

Differences from HTML

Document Structure

  • XHTML DOCTYPE is mandatory
  • The xmlns attribute in <html> is mandatory
  • <html>, <head>, <title>, and <body> are mandatory

XHTML Elements

  • XHTML elements must be properly nested
  • XHTML elements must always be closed
  • XHTML elements must be in lowercase
  • XHTML documents must have one root element

XHTML Attributes

  • Attribute names must be in lower case
  • Attribute values must be quoted
  • Attribute minimization is forbidden

<!DOCTYPE html....> Is Mandatory

An XHTML document must have an XHTML DOCTYPE declaration. A complete list of all the XHTML Doctypes is found in our HTML Tags Reference.

The <html>, <head>, <title>, and <body> elements must also be present, and the xmlns attribute in must specify the xml namespace for the document.

XHTML Elements Must Be Closed

<p>This is a paragraph</p>

Empty Elements Must Also Be Closed

This is a paragraph<br />
This is a horizontal line <hr />
This is a image tag <img src="pic.jpg" alt="picture" />

Convert from HTML to XHTML

  • Add an XHTML <!DOCTYPE> to the first line of every page.
  • Add an XHTML attribute to the html element of every page.
  • Change all element, attribute names to lowercase.
  • Close all empty elements.
  • All attribute values must be quoted with either single quotes or double quotes for example class=page is invalid but both class='page' and class="page" are correct
  • All attribute must have values.

Email Us: advertise@gdatamart.com

Donate Us: Support to GDATAMART

© 2023 GDATAMART.COM (All Rights Reserved)