Set - 3

Question 1 :

What's XHTML DTD? 

Answer :

The XHTML standard defines three Document Type Definitions.
The most common is the XHTML Transitional.
The <!DOCTYPE> Is Mandatory
An XHTML document consists of three main parts:
* the DOCTYPE
* the Head
* the Body

The basic document structure is:

<!DOCTYPE ...>
<html>
<head>
<title>... </title>
</head>
<body> ... </body>
</html>

The DOCTYPE declaration should always be the first line in an XHTML document.

An XHTML Example
This is a simple (minimal) XHTML document:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title>simple document</title>
</head>
<body>
<p>a simple paragraph</p>
</body>
</html>

The DOCTYPE declaration defines the document type:

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

The rest of the document looks like HTML:
<html>
<head>
<title>simple document</title>
</head>
<body>
<p>a simple paragraph</p>
</body>
</html>

The 3 Document Type Definitions
* DTD specifies the syntax of a web page in SGML.
* DTD is used by SGML applications, such as HTML, to specify rules that apply to the markup of documents of a particular type, including a set of element and entity declarations.
* XHTML is specified in an SGML document type definition or 'DTD'.
* An XHTML DTD describes in precise, computer-readable language, the allowed syntax and grammar of XHTML markup.

There are currently 3 XHTML document types:
* STRICT
* TRANSITIONAL
* FRAMESET

XHTML 1.0 specifies three XML document types that correspond to three DTDs: Strict, Transitional, and Frameset.
XHTML 1.0 Strict

<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Use this when you want really clean markup, free of presentational clutter. Use this together with Cascading Style Sheets.
XHTML 1.0 Transitional
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Use this when you need to take advantage of HTML's presentational features and when you want to support browsers that don't understand Cascading Style Sheets.
XHTML 1.0 Frameset
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
Use this when you want to use HTML Frames to partition the browser window into two or more frames


Question 2 :

What the benefits of XHTML are?

Answer :

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.


Question 3 :

Attributes values must be in double or single quotes ?

Answer :

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

 


Question 4 :

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

Answer :

<input type="text" value="Amazon.com" size="20" >
becomes 
<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 />"


Question 5 :

How to convert most HTML pages to XHTML?

Answer :

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>