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>

 


Question 6 :

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. 
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.

<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 7 :

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>

 


Question 8 :

How W3Schools Was Converted To XHTML ?

Answer :

W3Schools was converted from HTML to XHTML. 
To convert a Web site from HTML to XHTML, you should be familiar with the XHTML syntax rules. 
Your pages must have a DOCTYPE declaration if you want them to validate as correct XHTML. 
The following DOCTYPE declaration was added as the first line of every page: 
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


Be aware however, that newer browsers might treat your document differently depending on the <!DOCTYPE> declaration. If the browser reads a document with a DOCTYPE, it might treat the document as "correct". Malformed XHTML might fall over and display differently than without a DOCTYPE.

Lower Case Tag And Attribute Names
Since XHTML is case sensitive, and since XHTML only accepts lower case HTML tags and attribute names, a general search and replace function was executed to replace all upper case tags with lowercase tags. The same was done for attribute names. We have always tried to use lower case names in our Web, so the replace function did not produce many real substitutions.

All Attributes Were Quoted
Since the W3C XHTML 1.0 Recommendation states that all attribute values must be quoted, every page in the web was checked to see that attributes values were properly quoted. This was a time-consuming job, and we will surely never again forget to put quotes around our attribute values.

Empty Tags: <hr> , <br> and <img>
Empty tags are not allowed in XHTML. The <hr> and <br> tags should be replaced with <hr /> and <br />.

This produced a problem with Netscape that misinterpreted the <br/> tag. We don't know why, but changing it to <br /> worked fine. After that discovery, a general search and replace function was executed to swap the tags.

A few other tags (like the <img> tag) were suffering from the same problem as above. We decided not to close the <img> tags with </img>, but with /> at the end of the tag. This was done manually.

The Web Site Was Validated
After that, all pages were validated against the official W3C DTD with this link: XHTML Validator. A few more errors were found and edited manually. The most common error was missing </li> tags in lists.


Question 9 :

Downcase HTML tags, attributes, and HTML defined values ?

Answer :

<BODY BGCOLOR="RED">
becomes 
<body bgcolor="red">

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


Question 10 :

What XHTML does it stand for? How is if different from HTML? Who developed it?

Answer :

XHTML stands for "Extensible HyperText Markup Language". It was developed by the World Wide Web Consortium (W3C) and is now a W3C Recommendation.
XHTML is a reformulation of HTML 4 in XML 1.0. This means that the benefits provided by XML will be available to XHTML.


Question 11 :

How does HTML differ from XHTML ? 

Answer :

XHTML has a small number of differences. The most noticeable being the requirement for elements to be lowercase (e.g. <p> and not <P>) and elements to be closed (e.g. paragraphs must end with a </p>).


Question 12 :

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

Answer :

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> 
becomes 
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)+>
<!ATTLIST ol %attrs; 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. 
<ol>

These are some of my favorite animals:

<li>octopus</li>
<li>shrew</li>
<li>lemur</li>
and my most favorite
<li>meerkats</li>
</ol>

becomes

<p>These are some of my favorite animals:</p>
<ol>
<li>octopus</li>
<li>shrew</li>
<li>lemur</li>
<li>meerkats</li>
</ol>