Web Standard build Station-xhtml Basic Tutorial 1

Source: Internet
Author: User
Tags format closing tag compact end error code lowercase version
HTML Basic |web|web standard |xhtml| Basic Tutorial

Site original content, reproduced please indicate the source Web page teaching network .

  Objective:

Now all pay attention to the standard station, and the standard station uses the technology mainly is xhtml+css, but now we commonly use is the HTML code, then how should I transform? And what is the difference between HTML and XHTML? In this tutorial, you'll learn the difference between HTML and XHTML, and how to convert HTML to XHTML. After all, XHTML is the direction of development, so I think the tutorial is necessary to publish on this site. I feel that if you want to use the standard or the best to learn HTML first, because it is simpler, and then look at the tutorial.

  XHTML Introduction:

XHTML is the abbreviation for Extensible Hypertext Markup Language (Extensible Hypertext Markup Language), while HTML is hypertext Markup Language (Hypertext Markup Language), which is the difference between names. In fact, we say that the standard should be XML, then why learn XHTML? Because the current HTML code cumbersome, dangerous, but the XML use environment is not mature, so the introduction of an excessive product is XHTML, it plays a role to play. Others think XHTML is an upgraded version of HTML, but it's also true, and my understanding is that XHTML makes HTML a more canonical markup language, making HTML powerful and reducing the cumbersome code, especially the tables.

XHTML was set as a standard on January 26, 2000 by the International Standards Organization (World Wide Web Consortium), which is considered to be the latest version of HTML and will gradually replace HTML. All browsers now support xhtml,xhtml compatible HTML 4.0. Others think that XHTML is HTML4.01. If you have written a standard station for yourself in the course of your study, you can pass the verification of the XHTML1.0 and you will get a logo, usually a certificate of authentication and CSS validation. I'm not sure how many websites in the country have passed these two validations at the same time. You can go to http://www.w3.org/this site to verify your station, if the two rules will be given to us two pieces of code added to your page to show others that you use the standard build station AH, cow Ah!

  Why we use XHTML

XHTML is an overused product of HTML upgrades to XML and is defined as a standard, XHTML is fully compatible with HTML4.01, and has XML syntax. Here's a look at an HTML with an error code, as follows:

<title>this is bad html</title>

<body>

</body>

Although it contains the error code, it can be displayed normally when browsing in the browser. XML is a markup language, but it requires that any element that appears in a Web page should be marked, XML is used to describe the data in the Web page, and HTML is used to display the elements in the Web page. At present, we use a variety of Internet browser technology, including laptops, mobile internet browsing, and so on, all required to browse some of the content to be properly labeled, if there is a wrong mark may make the display particularly confusing, or even normal display.

So federated HTML and XML, and other technologies, we've got a language that's useful now and will be useful in the future-XHTML.

We'll need to start learning XHTML Now that we're going to use XHTML in the right format in the future, so that all browsers can execute correctly.

  The difference between XHTML and HTML:

XHTML is a new technology that we should be familiar with before browsers and other software support it. We should familiarize ourselves with HTML4.0 before we can learn more about XHTML, and we could download a reference manual to familiarize ourselves with it. To make it easier for us to learn XHTML, in other words, we should try to write less error code when we use HTML to write code, such as: write HTML with lowercase characters, and then tag the end of each tag like:<p> Web Teaching Network welcome you to visit </p > End must have, we want to keep this rule.

The biggest difference between them is:

  The 1.XHTML element must be used correctly in nesting.

Some elements in HTML can be incorrectly nested and can be displayed correctly, such as:

<b><i>this text is bold and italic</b></i>

The XHTML must be properly nested before it can be used properly, such as:

<b><i>this text is bold and italic</i></b>

Note: This error usually occurs when nested layers of tags are inside. Such as:

<ul>

<li>Coffee</li>

<li>tea

<ul>

<li>black tea</li>

<li>green tea</li>

</ul>

<li>Milk</li>

</ul>

The correct one should be:

<ul>

<li>Coffee</li>

<li>tea

<ul>

<li>black tea</li>

<li>green tea</li>

</ul>

</li>

<li>Milk</li>

</ul>

Looking at the above two pieces of code we can see the correct inside we insert </li> tags after </ul>.

  XHTML files must have the correct organizational format.

All XHTML should be properly nested within an element that starts with a

<body> ... </body>

  Label names must be in lowercase letters.

Because XHTML documents are XML applications, XML is sensitive to capitalization. Like <br> and <BR> are two different marks. such as error code:

<BODY>

<p>this is a paragraph</p>

</BODY>

The correct format is:

<body>

<p>this is a paragraph</p>

</body>

  All XHTML elements must be closed

There is no empty element that has not been closed in our code, in fact, for this we are relatively good end, there should be the beginning of the end? For example, error code:

<p>this is a paragraph

<p>this is another paragraph

Correct for:

<p>this is a paragraph</p>

<p>this is another paragraph</p>

  Independent of a label we also want to end with/>.

For example: Error code

This is a break<br>

Here comes a horizontal rule:

Here ' s an image

Correct code:

This is a break<br/>

Here comes a horizontal rule:

Here ' s an image

With a few examples of the above, we can basically see the difference between HTML and XHTML, so we should try to change our current HTML from now on, such as using lowercase tags, and/> with the closing tag after the tag.

  The syntax of XHTML

It's easy to say that writing XHTML uses clean HTML syntax.

Some other syntax requirements for XHTML:

  attribute names must be lowercase. such as:

Error code:

<table width= "100%" >

The correct code:

<table width= "100%" >

  property value must be referenced. such as:

Wrong code:

<table width=100%>

The correct code:

<table width= "100%" >

  the abbreviation for the attribute is prohibited. such as:

Wrong code:

<DL compact>

<input checked>

<input readonly>

<input disabled>

<option selected>

<frame noresize>

The correct code:

<DL compact= "compact" >

<input checked= "Checked"/>

<input readonly= "ReadOnly"/>

<input disabled= "Disabled"/>

<option selected= "Selected"/>

<frame noresize= "Noresize"/>

List A table to let you know:

HTML XHTML

Compact compact= "compact"

Checked checked= "Checked"

DECLARE declare= "DECLARE"

ReadOnly readonly= "ReadOnly"

Disabled disabled= "Disabled"

Selected Selected= "Selected"

Defer defer= "defer"

Ismap ismap= "Ismap"

Nohref nohref= "Nohref"

NoShade noshade= "NoShade"

nowrap nowrap= "NoWrap"

Multiple multiple= "multiple"

Noresize noresize= "Noresize"

  Replace the Name property with the id attribute. such as:

The name attribute is defined in HTML 4.01 for A,applet, frame, iframe, IMG, and map. In XHTML the Name property cannot be used and should be replaced with an ID. Such as:

Error code:

The correct code:

Note: We can also use both the ID and the name attribute in the label in order for the old browser to perform the content properly. Such as:

In order to adapt to the new browser browsing we ended up in the above code by adding/ending tags.



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.