[XHTML tutorial] Moving towards the XHTML standard (6) (XHTML howto)

Source: Internet
Author: User
Tags tidy

address: http://www.w3schools.com/xhtml/xhtml_howto.asp
: fan weixiao
XHTML howto
How can I convert my existing website to XHTML?
to convert a web site from HTML to XHTML, you should be familiar with the XHTML syntax rules of the previous chapters. the following steps were executed (in the order listed below):
converts an HTML website to XHTML, you should be familiar with the XHTML syntax rules described in the previous chapters. The following content will help you.

A doctype definition was added
The following doctype declaration was added as the first line of every page:
Set the following lineCodeAdd the first line of each page.

<! Doctype HTML public
"-// W3C // dtd xhtml 1.0 transitional // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

Note that we used the transitional DTD. We cocould have chosen the strict DTD, but found it a little too "strict", and a little too hard to conform.
Note that transtitional DTD is used here. Of course, we can also choose strict DTD, but we find it a little too strict, it is too difficult to follow it completely.

A note about the doctype
Your pages must have a doctype declaration if you want them to validate as correct XHTML.
If you want to make your page meet the correct XHTML validity, you must use the doctype declaration.
Be aware however, that newer browsers (like Internet Explorer 6) 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.
However, you must note that a newer browser (such as IE6) may treat the doctype statement on your page differently. If the browser reads a page containing the doctype declaration, it may regard the page as "correct ". If you do not use the malformed XHTML page of doctype, the above elements may be "dropped" and a different page is displayed.
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 returns real substitutions.
XHTML is case-sensitive and only accepts lower-case tags and attribute names. You can use the replace function to process them.
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.
Attribute should be caused by parentheses. There is no easy way to do this, but it is a time-consuming task. Remember to forget the brackets later.

Empty tags: <HR>, <br> and
Empty tags are not allowed in XHTML. The <HR> and <br> tags shocould be replaced with <HR/> and <br/>.

This produced a problem with Netscape that misinterpreted the <br/> tags. 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 tag) were suffering from the same problem as abve. we decided not to close the tags with </img>, but with/> at the end of the tag. this was done manually.
Too long. Mark 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.
Your website can be verified through the official XHTML validity checker. More errors will be checked out and the manual boundary will be reached, the most common error is that you forget to write in the list </LI>.
Shocould we have used a converting tool? Well, We coshould have used tidy.
You can use the tidy Conversion Tool.
Dave raggett's HTML tidy is a free utility for cleaning up HTML code. it also works great on the hard-to-read markup generated by specialized HTML editors and conversion tools, and it can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities.
Dave raggett's HTML tidy is a free software designed to optimize HTML code. It can also well handle obscure tags generated by special HTML editors and conversion tools. At the same time, it helps you identify whether your pages can be used by people with disabilities that you must pay attention to in the long run?
The reason why we didn't use tidy? We knew about XHTML when we started writing this Web site. we knew that we had to use lowercase tag names and that we had to quote our attributes. so when the time came (to do the conversion), we simply had to test our pages against the W3C XHTML validator and correct the few mistakes. and-we have learned a lot about writing "Tidy" HTML code.
The reason we don't use tidy is that when we do this website, we will know XHTML, And we will know in lower case and quotation marks. So when we need to convert, we simply use the W3C XHTML validators to correct a few of our errors. In addition, we have learned how to write clean HTML code.

A doctype definition was added
The following doctype declaration was added as the first line of every page:
Add the following line of code to the first line of each page.

<! Doctype HTML public
"-// W3C // dtd xhtml 1.0 transitional // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>

Note that we used the transitional DTD. We cocould have chosen the strict DTD, but found it a little too "strict", and a little too hard to conform.
Note that transtitional DTD is used here. Of course, we can also choose strict DTD, but we find it a little too strict, it is too difficult to follow it completely.

A note about the doctype
Your pages must have a doctype declaration if you want them to validate as correct XHTML.
If you want to make your page meet the correct XHTML validity, you must use the doctype declaration.
Be aware however, that newer browsers (like Internet Explorer 6) 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.
However, you must note that a newer browser (such as IE6) may treat the doctype statement on your page differently. If the browser reads a page containing the doctype declaration, it may regard the page as "correct ". If you do not use the malformed XHTML page of doctype, the above elements may be "dropped" and a different page is displayed.
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 returns real substitutions.
XHTML is case-sensitive and only accepts lower-case tags and attribute names. You can use the replace function to process them.
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.
Attribute should be caused by parentheses. There is no easy way to do this, but it is a time-consuming task. Remember to forget the brackets later.

Empty tags: <HR>, <br> and
Empty tags are not allowed in XHTML. The <HR> and <br> tags shocould be replaced with <HR/> and <br/>.

This produced a problem with Netscape that misinterpreted the <br/> tags. 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 tag) were suffering from the same problem as abve. we decided not to close the tags with </img>, but with/> at the end of the tag. this was done manually.
Too long. Mark 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.
Your website can be verified through the official XHTML validity checker. More errors will be checked out and the manual boundary will be reached, the most common error is that you forget to write in the list </LI>.
Shocould we have used a converting tool? Well, We coshould have used tidy.
You can use the tidy Conversion Tool.
Dave raggett's HTML tidy is a free utility for cleaning up HTML code. it also works great on the hard-to-read markup generated by specialized HTML editors and conversion tools, and it can help you identify where you need to pay further attention on making your pages more accessible to people with disabilities.
Dave raggett's HTML tidy is a free software designed to optimize HTML code. It can also well handle obscure tags generated by special HTML editors and conversion tools. At the same time, it helps you identify whether your pages can be used by people with disabilities that you must pay attention to in the long run?
The reason why we didn't use tidy? We knew about XHTML when we started writing this Web site. we knew that we had to use lowercase tag names and that we had to quote our attributes. so when the time came (to do the conversion), we simply had to test our pages against the W3C XHTML validator and correct the few mistakes. and-we have learned a lot about writing "Tidy" HTML code.
the reason we do not use tidy is that when we do this website, we will know XHTML, And we will know in lower case and quotation marks. So when we need to convert, we simply use the W3C XHTML validators to correct a few of our errors. In addition, we have learned how to write clean HTML code.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.