XHTML Interview Question and Answer

There are many things that you can do ahead of time to prepare for the interviewing process, and move yourself a step above of the competition. Updating your resume and reviewing frequently asked interview questions can be very effective, and goes a long way in getting the most out of your interview.

What the benefits of XHTML are?

As XHTML is an XML application, you will benefit from developments in the XML world. For example XML tools such as editors, converters, browsers, etc. can be used with XHTML resources. In addition there are developments to the XML family of protocols and formats which will provide additional functionality for XHTML.

Attributes values must be in double or single quotes

<ol type=1>
becomes
<ol type="1">
or
<ol type='1'>

Every element must have an end tag, even when it doesn't really matter.

<br>
<input type="text" value="Amazon.com" size="20" >

becomes
<br />
<input type="text" value="Amazon.com" size="20" />

For compatibility with older browsers its best to put a single space before the '/'. Some browsers have trouble with "<br></br>" so its best to use "<br />"

 

How to convert most HTML pages to XHTML.

1. Heading lines at top
At the beginning of documents we need to include a few lines:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

The location of the dtd allows validating parsers to check the document. Most browsers will ignore these tags.

Every attribute must have a value

<ol compact>
<input type="radio" name="title" value="decline" checked>decline</input>

becomes
<ol compact="compact" >
<input type="radio" name="title" value="decline" checked="checked">decline</input>