XHTML 1.0: mark a new beginning

Source: Internet
Author: User
Tags microsoft frontpage ibm developerworks


Familiarity and entry into new standards
Content: Are you still writing documents in HTML? If yes, the current standard is not met. In January 26, 2000, XHTML 1.0 became the W3C recommendation. According to W3C, HTML is no longer a web tag standard. In addition, XHTML 1.0 has replaced the old darling, marking the arrival of an exciting new era of communication technology.

So what is XHTML 1.0? What does it mean for Web developers? The following is a W3C Description: XHTML 1.0 is an XML application.Program. This means that if you use XHTML 1.0 to compile a document, the rules and concepts inherent in XML are applied to Web markup. Naturally, there is another question: Can I mark Web documents with XHTML 1.0? The answer is clear: "Yes ". All you need to do is to learn to correctly organize the document structure, select the correct document type definition (DTD), and learn several types of management.CodeA New Method for development.

But how can we get started with XHTML 1.0 so easily? When writing a document, you will see that it uses the HTML you are familiar with as its vocabulary. There are minor changes in methods, but there are major differences in thinking. XHTML 1.0 allows web authors to encode based on standards and begin to change future development and changes
Opinion.

Why is another markup language required?
HTML is quite easy to use. Indeed, we have been challenged by cross-browser and cross-platform solutions. However, as Web evolved from the early form of 1990s to the dynamic active web as we know today, it also means consuming, damaging, and even creating new HTML rules on the way forward.

Developers who have learned the HTML 4.0 standard know that the final goal of improving the HTML 4.0 standard has been determined when the HTML standard emerged. Some main considerations of HTML 4.0 include:

By separating basic formatting from Styles, you can organize documents against arbitrary or problematic elements.
The document type must be declared (and the author wants to follow the rules in the three DTD of HTML 4.0 in the Declaration)
These principles all exist in XHTML 1.0, but they are combined with the concepts in XML. These concepts help improve the markup beyond just enhancing its basic syntax. XHTML 1.0 has many targets, but includes the following:

Provides the foundation for Web tag scalability
Provides the same or better interoperability through the past, present, and future browsers
With the coming XHTML version, other XML applications, and emerging technologies (such as wireless and New Device Development), the author prepares for the ever-evolving opportunities. The most convincing reason for adopting XHTML 1.0 is that developers (especially those who study HTML or who use visual design tools to achieve their goals) can learn this standard, to easily move to other XML applications. Then they can see the power of XML and scalability. Because the process is similar: HTML vocabulary adds some new structures and syntax methods, XHTML 1.0 makes XML and its application fields no longer daunting.

By using familiar languages and new concepts, it is easy to move into unfamiliar fields. For example, the knowledge of XHTML 1.0 can be simplified to the upcoming XHTML version and the XML technology related to wireless and other applications (such as WML (Wireless Markup Language), SMIL (synchronous multimedia language) and SVG (Scalable Vector Graphics )).

Root Cause of inquiry
Exploring the source of XHTML helps you understand the basic principles of XHTML and guide its rules.
The root cause of XML and HTML is SGML, that is, standardized General Markup Language ). It is important that SGML is not a language. It is a known metalanguage, that is, a language that contains rules used to develop other languages.

Like SGML, XML is also a metalanguage. As in this case, the rules are used to create an XML application. XHTML is an XML application that uses HTML, another SGML language, as its vocabulary.

If the relationship looks complicated, it is because it is indeed complicated. SGML first generates HTML and then XML. When you are aware of the worries and restrictions of HTML, XML rules can clearly enable HTML to become a markup language that helps developers remove these restrictions.

First, demand
Several requirements and rules must be taken into account to make the XHTML 1.0 document conform to its metabase (XML. As follows:

We recommend that, but do not require the use of XML declarations to declare XHTML 1.0 documents as XML documents.
It is required that the XHTML 1.0 document contain a doctype, specify this document as XHTML 1.0, and specify the DTD used for this document.
The XHTML 1.0 document has a root element <HTML>. The Start mark of the HTML element should contain the XML namespace xmlns and the appropriate values of the namespace.
The syntax and structure of the document must comply with the XHTML syntax rules.
The first step to achieve this goal is to correctly organize the structure of the XHTML 1.0 document. It starts with adding correct statements and Document Information.

Document declaration, type, and namespace
The XHTML 1.0 document can contain several structural elements to be considered correct: an XML declaration, a doctype Declaration, and a namespace.
The XML Declaration allows the author to declare the document as XML and include the encoding used by the document.
<? XML version = "1.0" encoding = "UTF-8"?>
As mentioned above, we recommend that you use this statement, but this is not necessary. Some of the reasons for unforced use are: If used, Some browsers (including ie 4.5for Mac and Netscape 4.0 for Windows) will display incorrect XHTML pages. Therefore, most authors of XHTML 1.0 who are interested in interoperability do not use it. However, because encoding information is very important in many cases (especially when using international documents), if you do not use XML declarations, you are encouraged to add encoding information to the meta tag (shown in Listing 2 ).

Under the XML Document declaration-if you choose not to use it, it is located at the top of the document-the doctype Declaration must be placed. Doctype allows the author to declare the document type used. In this example, the document type is XHTML 1.0. The document must comply with the specific XHTML 1.0 DTD as strict.

There are only three DTD types in XHTML 1.0. They are from HTML 4.0 and the content is as follows:

Strict: strict follows the strictest XHTML rules. In a document of this type, only the current element, attribute, and character entity are allowed. Elements opposed to HTML 4.0 (such as font or center) are not allowed ). And do not allow obsolete elements. The strict statement is as follows:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 strict // en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict. DTD">
Transitional: the transitional XHTML 1.0 document is more tolerant and allows the author to use the opposed and current methods. You can use font or center in the transitional document, or any other flag that is opposed, as long as the document itself is correctly marked. Do not use outdated elements. If you are writing transitional documents in XHTML 1.0, the following statements are included:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en"
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional. DTD">
Frameset: The frameset DTD is reserved only for the frameset document. Frameset documents that comply with this DTD can be marked with strict or transitional. To create a frameset document with XHTML 1.0, include the doctype at the top of the document:
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 frameset // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd>
After determining whether to use the XML declaration and adding the doctype declaration that defines the tag rules to be followed, you need to add the HTML root to the document and set the XHTML namespace accordingly:
<HTML xmlns = "http://www.w3.org/1999/xhtml">
In this case, you need to add some necessary structural elements, such as head, title, and body. Listing 1 shows the XML Declaration of the XHTML 1.0 transitional document shell. In Listing 2, you will see the transitional document without XML declaration, but there is a meta tag to declare the character set used.

Listing 1: XHTML 1.0 documents in transitional DTD format with XML declarations
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> transitional document with XML declaration </title>
</Head>
<Body>
</Body>
</Html>
In Listing 2, you will see the transitional document without XML declaration, but there is a meta tag to declare the character set used.

Listing 2: XHTML 1.0 documents in transitional DTD format without XML Declaration
<! Doctype HTML public "-// W3C // DTD xhtml1.0 transitional // en"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd>
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Title> transitional document without XML declaration </title>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
</Head>
<Body>
</Body>
</Html>

Syntax
Once the XHTML document contains the required declaration and structure information, you can check the syntax changes caused by the impact of XML on Web tags. These syntax changes include case-sensitive, correctly formatted tag elements, empty and non-empty elements, and the use of quotation marks.

Case sensitivity
As you know, HTML is case-insensitive. This means that the names of HTML elements and attributes can be uppercase, lowercase, or lowercase. Therefore, you can write it as follows:
<Body background = "my.gif">
Or
<Body background = "my.gif">
Even
<Body background = "my.gif">
All these examples have the same functions. On the other hand, XML is case sensitive. Therefore, XHTML requires a specific case. In XHTML 1.0, all element and attribute names must be in lowercase:
<Body background = "my.gif">
Except for element and attribute names, XHTML 1.0 is not required. Note that the attribute values (for example, "my.gif") can be case-insensitive. If the file system on the server where the file is located is case-sensitive or uses case-sensitive code in applications (for example, those Active Server Pages using Microsoft (ASP), ASP +, or ColdFusion code.

Good format
Although many HTML browsers are very tolerant, many html tools do not comply with the standards. In this way, some authors develop bad habits, such as incorrect tag nesting. The following example can be used in many browsers:
<B> <I> welcome to mysite. com </B> </I>
In a tolerant browser, it is displayed in bold and italic. However, if you pick up the pen, mark it from the beginning of the bold to the end of the mark to draw an arc, and then mark it from the beginning of the Italic to the end mark to draw an arc, you will see, the two arcs intersect. This shows incorrect tag nesting, which we think is a bad format.

In XHTML 1.0, such bad format tags are not accepted. The concept of "Each element must be correctly nested" must be well-formatted. In the preceding example, XHTML 1.0 is used:
<B> <I> welcome to mysite. com </I> </B>
Now, draw an arc and you will see that the arc is no longer intersecting. These tags are placed in the correct order and are considered to be in the correct format.

Non-empty and empty elements
A non-empty element contains one element and some content:
<P> This is the content within a non-empty element. </P>
On the contrary, empty elements have no content, but only elements and their attributes, such as <HR> and .

XML rules indicate that the empty and non-empty elements must be completely disabled. In HTML, we can see that non-empty elements usually have some optional end tags. The preceding section can be written as follows:
<P> This is the content within a non-empty element.
In HTML, this is correct. XHTML 1.0 requires that non-empty elements be completely disabled. Another example is the <li> (list item) element. In HTML, you can write it as follows:
<Li> The first item in my list.
<Li> the second item in my list.
Or
<Li> The first item in my list. </LI>
<Li> the second item in my list. </LI>
In XHTML 1.0, only the last method is allowed.

In XML, use a slash to terminate an empty element. Therefore, it becomes <br/>. Some browsers that are used to interpreting HTML may encounter problems when using this method. Therefore, an alternative method is introduced to add a space before the Slash: <br/>.

This is an XHTML example of an image element. It is an empty element:

Other empty elements are Meta and link.

Quotation marks
The quotation marks in HTML are arbitrary, that is, you can use quotation marks before and after the attribute values, or you can not use them, without causing too much trouble. There is no rule to say that it is invalid to enclose the value without quotation marks. The following example is completely acceptable in HTML:
<Table border = 0 width = "90%" cellpadding = 10 cellspacing = "10">
Although some property values are enclosed in quotation marks and some are not, the browser displays the tag correctly. However, to comply with XHTML 1.0, all attribute values must be enclosed in quotation marks.
<Table border = "0" width = "90" cellpadding = "10" cellspacing = "10">
As you can see, these changes are not large. A little annoying. Yes, but once you start using this method, you will find it much easier to mark it. Consistent
Sex is one of the reasons for making XHTML 1.0 so attractive-it provides a solid foundation for building future structures.

Future of XHTML
Since XHTML is so easy to use, why have it been used for so long? This is a question that many people are concerned about. This problem may be partly caused by insufficient publicity-Not many people understand XHTML 1.0. Even if you have heard of it, you may not realize how easy it is to use it.

Another reason is that the software tools currently used for HTML development (such as Adobe golive, Macromedia Dreamweaver, and Microsoft FrontPage) do not support xthml, many Web authors who love these tools or must use them at work are worried about this.

However, despite these difficulties, XHTML 1.0 is moving forward. In fact, the next version, XHTML 1.1, is quite well-developed and contains some new and different concepts of Web tag authors. Modularization (dividing languages into independent modules) is a major part of XHTML 1.1. In addition, more advantages similar to XML play a role. For example, writing your own DTD or schema for the XHTML document brings real scalability.

XHTML 1.0 is today's Web tag standard. If you haven't used it yet, at least try it. The progress in XML-related technical fields (especially in the wireless field) strongly and confidently shows that the more flexible the markup language author is, the more promising it will be. XHTML 1.0 is an excellent way to broaden your horizons. It makes sense to be familiar with it. It is powerful enough to help you create stable and interoperable web sites suitable for today and tomorrow's exciting opportunities.

References

World Wide Web Consortium XHTML recommendation. This is the standard document for detailed explanation of XHTML 1.0 on the W3C site
XHTML 1.1. Under discussion, the next version of XHTML involves the modularization of XHTML 1.0.
you can find the Web Review Series on XHTML 1.0 by Chuck musciano.
baiquito. com is a web site of baiquito technologies. It creates software products for XHTML. You can also find a good
tutorial and a large number of resource links on their sites.
about the author
as a writer, lecturer, and designer, Molly E. holzschlag brings his views and enthusiasm to books, magazines, and web sites. One of the 25 most influential women on the web, Molly has been working in the online world for 10 years. She wrote 15 books about html and web design and development subjects
, including the soon-to-be-published que Special Edition using XHTML 1.0, the best-selling special edition using HTML
4.0, and internationally acclaimed Web by design. Her popular topic, integrated design, appears in the webtechniques magazine every month.
she is also the executive editor of Web Review, which is also Adobe magazine and builder. com, designshops.com, digital Chicago, digital New York, IBM developerworks, MacWorld, msdn, and planetit writers are also members of other developer resources. Visit her website http://www.molly.com /.

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.