Документация
HTML CSS PHP PERL другое
Converting HTML Documents to XHTML
 
Previous Page
Table of Contents
Next Page

Converting HTML Documents to XHTML

it isn't too terribly difficult to bring HTML 4 documents up to par with the XHTML 1.1 specification. You've already learned about the ways in which XHTML documents differ from HTML documents. These differences become your guide to converting HTML to XHTML.

Following is a checklist to use as a guide while performing the conversion from HTML to XHTML:

1.
Add a document type declaration that declares the XHTML 1.1 DTD.

2.
Declare the XHTML 1.1 namespace in the html element that matches the DTD.

3.
Convert all element and attribute names to lowercase.

4.
Match every start tag with an end tag.

5.
Replace > with /> at the end of all empty tags.

6.
Enclose all attribute values in quotes (").

7.
Make sure that all elements and attributes are defined in the XHTML 1.1 DTD; use CSS styles to replace deprecated presentation tags.

8.
Convert special characters to entity references; for example, " becomes " (see Table D.1 for more details).

Table D.1. Characters to Avoid Using in XHTML Pages

Replace This…

With This…

& (ampersand)

& or &

" (quotation/inch mark)

" or "

< (open angle bracket)

&lt; or &#60;

> (close angle bracket)

&gt; or &#62;

[ (open square bracket)

&#91;

] (close square bracket)

&#93;

' (apostrophe/single quote)

&#39;


Did you Know?

If you have a number of HTML pages that you'd like to convert to XHTML-compatible format, I strongly recommend that you download the free HTML-Kit software from http://www.chami.com/html-kit/ is also a friendly and well-designed text editor with many handy features for writing new XHTML pages. (One caveat: HTML-Tidy changes the line breaks and spacing of your code, so you may have to do some reformatting by hand if you like to neatly indent your code.)


see whether your pages adhere completely to the official XHTML standard. The validation service, located at http://validator.w3.org/ the final word on the accuracy of XHTML code.

existing pages that don't conform to XHTML, you should be able to methodically tackle the conversion by following the steps mentioned in this appendix. If you carry out each of these steps, you should arrive at a legitimate XHTML document that conforms to all the rules of the XHTML 1.1 standard.


Previous Page
Table of Contents
Next Page


 Приглашаем посетить сайты 
Мода Чехов Крылов Автомобили Просвещение Культурология Спорт Пушкин Есенин CSS