XHTML Interview Questions & Answers part 3


Q: – How To Get Ready For XHTML?

XHTML is not very different from HTML 4.01, so bringing your code up to the 4.01 standard is a good start. In addition, you should start NOW to write your HTML code in lowercase letters.
The Most Important Differences:

* XHTML elements must be properly nested
* XHTML documents must be well-formed
* Tag names must be in lowercase
* All XHTML elements must be closed

Q: – Ampersands in hrefs must convert "&" to "&" in the URI

<a href="http://www.phonelists.com/cgi-bin/Handler.pl?ListID=Test&Password=test&action=View">Sample List</a>

<a href="http://www.phonelists.com/cgi-bin/Handler.pl?ListID=Test&Password=test&action=View">Sample List</a>

# The attribute "name" becomes "id" when used for a locator inside a document

For example, to reference a section within a document with a URI, we usually do something like
"<a href="favoriteAnimals.html#meerkats">Meerkats</a>"

Inside the referenced section,
<a name="meerkats"><h2>Meerkats of Africa</h2></a>

<a id="meerkats"><h2>Meerkats of Africa</h2></a>
or better yet for backwards compatibility:
<a id="meerkats" name="meerkats"><h2>Meerkats of Africa</h2></a>
# Tidy
tidy is a tool to automatically convert HTML to XHTML. You can find it at http://www.w3.org/People/Raggett/tidy/.

Q: – Downcase HTML tags, attributes, and HTML defined values


<body bgcolor="red">
(Capitols are ok in user defined attribute values like <img src="…" alt="My Favorite Picture">.)

Q: – What's about an assumption with XHTML?

Serving XHTML with a MIME type of text/html is wrong. The whole point of XHTML is that it’s XML so that you can benefit from namespaces and the like. If you serve it as text/html, you can’t:
In particular, ‘text/html’ is NOT suitable for XHTML Family document types that adds elements and attributes from foreign namespaces, such as XHTML+MathML [XHTML+MathML].
Source: http://www.w3.org/TR/xhtml-media-types/#text-html
Two choices:
1. XHTML 1.0 served as application/xhtml+xml to conforming UAs, and text/html to Internet Explorer
2. HTML 4.01, served as text/html
XHTML 1.1 is not an option because it mandates a MIME type of application/xhtml+xml which is incompatible with Internet Explorer

Q: – Why to type a tags in uppercase, and never bother closing the paragraphs ?

For reasons on internationalisation XML elements are case sensitive. A choice had to be made, and lowercase won on the day.
Tags may not overlap
This is <em> emphasized text and <b>bold </em>text</b>
This is <em>emphasized text </em> is <b>bold text</b>
Only certain tags may nest inside other tags
Looking at the dtd for xhtml, the definition of the "ol" element is:
<!ELEMENT ol (li)+>
type %OLStyle; #IMPLIED
compact (compact) #IMPLIED
start %Number; #IMPLIED
This implies that an order list, "ol", element may not contain paragraph tags or body text, just list items.
These are some of my favorite animals:
and my most favorite
<p>These are some of my favorite animals:</p>

Q: – XHTML should be the master storage format for my resources?

NO! XHTML still lacks semantics. Ideally your resources should be stored in an appropriate XML format. XSLT can then be used to convert the resources to XHTML (for Web browsers), WML (for mobile phones), etc. XHTML is a useful intermediate stage.

Q: – Can we get down to practicalities. How do I create XHTML pages?

The eGroups XHTML-L Web site provides links to XHTML tools, including conversion tools and editors. A couple of free tools are available (HTML-Kit, 1st Page 2000). Mozquito Factory appears to be the first licensed package on the market.
You can expect the usual suspects (Microsoft, Dreamweaver, etc) to bring out new versions of their products with XHTML support.

Q: – What about conversion of existing HTML pages – especially bulk conversion, as I have many thousands of HTML files!

W3C has written a utility program called Tidy which can be used to convert HTML pages to XHTML. Tidy can be used in batch mode to bulk-convert documents. Tidy is an open source program, which has been incorporated into an number of authoring tools, most notably HTML-Kit

Submitted By:– Nitu Chabra            Email-ID: – nituchabra@mail.com