[Web] Forgotten knowledge point-XHTML

Source: Internet
Author: User

Preface

First of all, I would like to ask you a question: do you use uppercase or lowercase letters when writing HTML code? Some people say it is in lower case, others say it is in upper case, and others say it is okay. I would like to say it is better to use lower-case letters for the following reasons: lower-case letters are more readable, and lower-case letters can make your code more compatible with XML code specifications (if you use XHTML, you need to do so ).

Here we introduce XHTML, so what is XHTML, what is its relationship with HTML, and what specifications it has. XHTML is a more rigorous HTML, which is published by W3C and used to help webpage developers transition from HTML to XML. Therefore, you can understand XHTML as an intermediate product of HTML and XML. It not only has the page appeal caused by HTML, but also has the specifications brought about by XML's rigor.

XHTML

Next I will list the things that need special attention when writing XHTML code:

  1. The root element of the document must be html
  2. The root element of the document must contain an xmlns attribute to declare the namespace of XHTML)

<HTML xmlns = "http://www.w3.org/1999/xhtml" XML: lang = "en" lang = "en">

  1. A doctype declaration is required and must be defined before the HTML element.

All XHTML documents must contain the doctype declaration. Likewise, documents must contain common HTML, Head, title, and body elements.

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

  1. All XHTML tags must be in lowercase.

Incorrect syntax: <a href = "/XHTML/xhtml_tutorial.html"> XHTML tutorial </a>

Correct syntax: <a href = "/XHTML/xhtml_tutorial.html"> XHTML tutorial </a>

  1. All marking elements must follow the "open and closed" principle.

Incorrect syntax:

Correct syntax:

  1. Attribute values of all elements must be enclosed in quotation marks.

Incorrect syntax:

Correct syntax:

  1. The omission of some attributes is not allowed, and the attributes must comply with the "key-value" principle.

Incorrect syntax: <option selected>

Correct syntax: <option selected = "selected">

  1. Use the ID attribute to replace the name attribute

Incorrect syntax:

Correct syntax:

  1. The language attribute marked by the script is outdated. Do not use

Incorrect syntax:

<Script language = "JavaScript" type = "text/JavaScript">

Document. Write ("Feel free to link to this XHTML tutorial! ");

</SCRIPT>

Correct syntax:

<script type="text/javascript" >
  document.write("Feel free to link to this XHTML Tutorial!");
</script>
  1. Correct use of tag nesting

Incorrect syntax:<b><i> This text is bold and italic</b></i>

Correct syntax:<b><i> This text is bold and italic</i></b>

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.