XML - Managing Data Exchange/XHTML/Answers

XHTML Chapter => XHTML

XHTML Exercises => Exercises

Answer
1. Change the HTML document below into an XHTML document conforming to the W3C's transitional standard. Validate your page using the validator available at http://validator.w3.org/.

Exercise 1
Below is an example of an invalid HTML document that contains a number of deprecated features. It is also badly structured. The document needs converting to XHTML with the content separated from the presentation.

Exercise 1.a.
a. Change the HTML document into a valid XHTML 1.0 Transitional document. Validate your page using the validator available at http://validator.w3.org/.

The XHTML 1.0 Transitional document:   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  Convert HTML to XHTML XHTML page It is important for your site to be current with the most recent W3C standards. Welcome to my page.

I hope that you enjoy your stay.  XHTML is similar to HTML Validator

Exercise 1.b.
b. Starting with the model answer for question 1.a. identify all deprecated elements and attributes in the document and replace them with CSS in a linked external stylesheet. See HyperText Markup Language/Tag List for details of deprecated elements.

The deprecated features are:
 * the  attribute of the   element;
 * the  element; and
 * the.

A possible stylesheet is:  body { color:blue }

span#welcome { text-decoration:underline /* It is generally a bad idea to underline anything other than hyperlinks. */ }

p.highlight { color:#9900FF; font-size:150%; font-family:Arial,sans-serif /* It is good practice to include one as the CSS generic font families, e.g. sans-serif, as an alternative. */ }

The document with deprecated features removed &#8211; note the use of the  and   attributes to provide hooks for the CSS selectors.   <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  Convert HTML to XHTML  XHTML page It is important for your site to be current with the most recent W3C standards. Welcome to my page.

I hope that you enjoy your stay. XHTML is similar to HTML Validator</a>

Exercise 1.c.
c. Starting with the model answer for question 1.b. replace all presentational markup with semantic markup and ensure that all inline elements are contained in block-level elements. Change the DOCTYPE to XHTML 1.0 Strict and validate the page with the W3C Markup Validation Service.

The presentational elements are:

The 'paragraph' beginning with a  element is a mixture of inline elements and text and so should be contained in a block-level element such as   (paragraph).

The  (anchor) element is inline and needs enclosing in a block-level element.

<blockquote style="background: white; border: 1px solid black; padding: 1em;"> <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> Convert HTML to XHTML <link rel="stylesheet" type="text/css" href="style.css" /> XHTML page It is important for your site to be current with the most recent W3C standards. Welcome to my page. I hope that you enjoy your stay. XHTML is similar to HTML <a href="http://validator.w3.org">Validator</a>

XHTML Chapter => XHTML

XHTML Exercises => Exercises