XHTML document declarations Web Designing

Every XHTML file must begin with declarations that tell the browser which versions of XML and XHTML are used in the document. The browser uses this information to display the document correctly. For XHTML, this element is required. The following is a minimal XHTML document:

<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
<head><title>Title is required</title></head><body> ..content of document...</body></html>

Let's look at this sample one element at a time. The document begins with an XML declaration (beginning with <? and ending with ?>) that tells the XML processor that the document uses XML Version 1.0.

The encoding attribute specifies the 8-bit Unicode character set (the most common). Be sure that the encoding value matches the character set used in your document.

The next element is the DOCTYPE declaration (the same as we've seen in XML and even regular HTML documents) that references the Transitional DTD, both by a public identifier and via a URL. If your document follows the strict XHTML version, use this declaration:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN">

And if it is a framed document, use the following:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN">

Finally, there are a few more directions added within the <html> tag for the document. The xmlns attribute specifies the primary namespace for the document. A namespace is a unique collection of tags and attributes that can be referenced by the browser.

More than one namespace may be referenced within a document, for instance, if the document contains other XML applications such as Scalable Vector Graphics (SVG) or MathML. The lang attribute is used to declare that the document language is English, for both the XML and XHTML namespaces.

All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Web Designing Topics