XHTML 1.0: Mark a New Beginning

Source: Internet
Author: User
Tags add format character set empty file system include version microsoft frontpage
Xhtml

Familiar and getting started with the new standard: Still writing documents in HTML? If so, it is not in line with current standards. January 26, 2000, XHTML 1.0 is a recommendation of the World Wide Web Consortium (WWW). According to W3c,html is no longer a WEB markup standard. Instead, XHTML 1.0 has replaced the old darling, marking the advent of an exciting new era of communication technology.

So, what exactly is XHTML 1.0? What does it mean for WEB developers? The following from the description of the consortium: XHTML 1.0 is the HTML of an XML application to be formed. This means that if you are documenting with XHTML 1.0, you apply the rules and concepts inherent in XML to Web tags. Naturally, there's a rocking question: Can you now Mark Web documents with XHTML 1.0? The answer is clear: "Yes". All you have to do is learn to organize the document structure correctly, select the correct document type definition (DTD) You need, and learn several new ways to manage code development. But how can XHTML 1.0 be so easy to get started with? When you write a document, you will see that it uses the familiar HTML as its vocabulary. With a minor change in approach, and a major difference in thinking, XHTML 1.0 allows WEB authors to encode based on standards and begin to change views about future developments and changes.

Why do I need a different markup language?

HTML is pretty good to use. Indeed, we have been challenged by the fact that we have a cross browser, Cross-platform solution that really works. However, as the web evolved from its early form in the 90 to the dynamic web of activity we know today, it also means consuming, destroying, or even creating new HTML rules on the way forward.

Developers who have studied the HTML 4.0 guidelines know that the ultimate goal of improving HTML guidelines has been identified when the HTML 4.0 standard emerges. Some of the main considerations for HTML 4.0 include:

Organize your document against the use of arbitrary or problematic elements by separating the basic formatting from the style
Requires declaring a document type (and, in a declaration, the author follows the rules in the three DTD of HTML 4.0)
These principles all exist in XHTML 1.0, but they are combined with the concepts in XML that help improve markup beyond just strengthening its basic syntax. XHTML 1.0 has many goals, but includes the following:

Provides the basis for extensibility in Web markup

Delivers the same or better interoperability through past, present, and future browsers

With the upcoming XHTML version, other XML applications, and emerging technologies such as wireless and new device development, the authors prepare for the evolving opportunities. One of the most compelling reasons to adopt XHTML 1.0 is that developers (especially developers who educate themselves through HTML, or who rely on visual design tools to achieve their goals) can easily move to other XML applications by learning that standard. Then they can see the power of XML and extensibility. Because the process is similar: the HTML vocabulary plus some new structure and syntax methods, XHTML 1.0 makes the domain of XML and its applications no longer daunting. By using familiar language and some new concepts, it is easy to move into unfamiliar areas. For example, the knowledge of XHTML 1.0 simplifies the process of transferring to upcoming XHTML versions and related XML technologies for wireless and other applications (such as WML (Wireless Markup Language), SMIL (Synchronized multimedia language), and SVG (Scalable Vector graphics).

Exploring the root of the problem

Exploring the source of XHTML helps to understand the fundamentals of XHTML and the rules that guide it.

The same source of XML and HTML is SGML, the standard Universal Markup Language (standardized general Markup Language). One thing is important: SGML is not a language in itself. It is known as the meta language--the language that contains the rules by which other languages are developed.

XML, like its source SGML, is also a meta language. As such, its rules are used to create XML applications. XHTML is an XML application that uses another SGML language, HTML, as its vocabulary.

If the relationship looks a little complicated, it's because it's really complicated. SGML first produces HTML, then XML. When aware of the concerns and limitations of HTML, XML rules can obviously make HTML grow into markup languages that help developers break away from these limitations.

First, there are several requirements and rules that need to be considered for the XHTML 1.0 document to conform to its meta language (XML). As shown below:

It is recommended, but not required, to declare an XHTML 1.0 document as an XML document using an XML declaration. The XHTML 1.0 document is required to contain a DOCTYPE, indicating that it is an XHTML 1.0 document and indicating the DTD used for that document. The XHTML 1.0 document has a root element .  The opening tag of the HTML element should contain the XML namespace xmlns and the appropriate value for that namespace. The syntax and structure of a document must conform to the XHTML syntax rules. The first step in achieving this goal is to properly organize the structure of the XHTML 1.0 document. Starts with adding the correct declaration and document information.

Document declarations, types, and namespaces

XHTML 1.0 documents can contain several structural elements to be considered correct: an XML declaration, a DOCTYPE declaration, and a namespace.

XML declarations allow authors to declare their documents as XML and include the encoding used by the document.

As mentioned earlier, it is recommended that this declaration be used, but this is not required. Part of the reason for not forcing is that, if used, some browsers (including IE 4.5for Mac and Netscape 4.0 for Windows) will display incorrect XHTML pages. Therefore, most XHTML 1.0 authors who are interested in interoperability do not use it. However, because encoding information is important in many cases (especially when working with internationalized documents), if you do not use an XML declaration, you are encouraged to add the encoding information in the META tag (shown in Listing 2 later).

Below the XML document declaration-If you choose not to use it, at the top of the document-you must place the DOCTYPE declaration. DOCTYPE allows the author to declare the type of document used. In this case, the document type is XHTML 1.0, and the specific XHTML 1.0 DTD that the document is to conform to is strict.

There are only three types of DTDs in XHTML 1.0. They come from HTML 4.0, which reads as follows:

Strict:strict adheres to the strictest XHTML rules. In a document written in this type, only the current element, attribute, and character entity are allowed to appear. Elements (such as font or center) that are opposed by HTML 4.0 are not allowed to appear. Obsolete elements are also not allowed. The STRICT statement reads as follows:
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
The Transitional:transitional XHTML 1.0 document is more forgiving, allowing authors to use the opposing and current methods. You can use font or center in a transitional document, or any other object that is objected to, as long as the document itself is marked correctly. Obsolete elements should not be used. If you are writing a transitional document with XHTML 1.0, the following statement will be included:
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
The Frameset:frameset DTD is reserved for Frameset documents only. Frameset documents that conform to the DTD can use strict or transitional tags. To create the frameset document in XHTML 1.0, include this DOCTYPE at the top of the document:
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd" >
After determining whether to use an XML declaration, and after adding a DOCTYPE declaration that defines the tagging rules to follow, you need to add the HTML root to the document and set the XHTML namespace accordingly:

At this point, you want to add some of the required structural elements, such as head, title, and body. Listing 1 shows the XHTML 1.0 Transitional document shell that includes the XML declaration. In Listing 2, you see a transitional document without an XML declaration, but there is a meta tag to declare the character set used.

Listing 1: XHTML 1.0 document with XML Declaration transitional DTD
 
"http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "> 
 
 
transitional Document with XML declaration 
 
 

 
in Listing 2, you will see a transitional document without an XML declaration, but there is a meta tag to declare the used character set.

Listing 2: XHTML 1.0 document with transitional DTD format without XML declaration
"Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >


transitional Document without XML declaration




Grammatical matters
Once the XHTML document contains the required declaration and structure information, you can examine the syntax changes that result from XML's impact on the Web markup. These syntax changes include case-sensitive, properly formatted markup elements, empty and non-empty elements, and the use of quotes.

Case
As you know, HTML is case-insensitive. This means that HTML element and attribute names can be mixed in uppercase, lowercase, or case. Therefore, it can be written as:

Or

Even

All of these examples have the same functionality. XML, on the other hand, is case-sensitive. Therefore, XHTML requires a specific case. In XHTML 1.0, all element and attribute names must be lowercase:

Other than element and attribute names, you do not have to follow XHTML 1.0. Note that property values, such as "http://www.webjx.com/htmldata/2006-03-03/my.gif", can be mixed in case. This is especially true if the file system on the server is case-sensitive, or if you use mixed-case code in your application, such as those written by Microsoft's Active Server Page (ASP), asp+, or ColdFusion.

A good format
Although many HTML browsers are tolerant, many HTML tools do not conform to the standard. In this way, some authors develop bad habits, such as improper markup nesting. The following example can be used in many browsers:
welcome to Mysite.com
In a tolerant browser, it displays bold and italic. However, if you pick up the pen, draw an arc from the beginning of the bold to its closing tag, and then draw an arc from the beginning of the italic to its closing tag, and you will see that the two arcs intersect. This shows an incorrect tag nesting, which we think is a bad format.

In XHTML 1.0, such bad formatting marks are not accepted. You must conform to the concept of good format for "each element must be nested correctly". The preceding example is expressed in XHTML 1.0 as:
welcome to Mysite.com
Now, if you draw an arc, you will see that the arc no longer intersects. These tags are placed in the correct order and are considered to be the correct format.

Non-empty and empty elements
A non-empty element contains an element and some content:

this is the content within a non-empty element.


In contrast, empty elements have no content, only elements and their attributes, such as and .

XML rules indicate that empty elements and non-null elements must be completely closed. In HTML, you can see that a non-empty element usually has an optional closing tag. The previous paragraph can be written like this:

this is the content within a NON-EMPTY element.
In HTML, think this is correct. XHTML 1.0 requires that non-empty elements be completely closed. Another example is the

  • (list item) element. In HTML, you can write:

  • the the My list.
  • the second item in the My list.
    Or
  • the the My list.

  • the second item in the My list.

  • In XHTML 1.0, only the latter method is allowed.

    In XML, the empty element is terminated with a slash. So, it becomes
    . Because some browsers that are accustomed to interpreting HTML have problems using the method, an alternative approach is to add a space before the slash:
    .

    This is an XHTML example of an image element, which is an empty element:

    Other empty elements to be aware of are meta and link.

    Quotes
    The quotes in HTML are arbitrary, that is, you can use quotes before and after the property value, and you can not use it, and it doesn't cause too much trouble. There is no rule saying: it is illegal to enclose values without quotes. The following example is entirely acceptable in HTML:



    Although some property values are enclosed in quotes, some do not, but the browser displays the tag correctly. However, if you want to follow XHTML 1.0, you must enclose all property values in quotation marks.




    As you can see, these changes are not significant. It's a bit annoying, yes, but once you start using this method, you'll find that it's much more convenient. ConsistentSex is one of the reasons why XHTML 1.0 is so appealing-it provides a solid foundation for building future structures.

    The future of XHTML
    Since XHTML is so easy to use, why does it take so long to be adopted? This is a question that many people who care about the standards are asking. Part of the problem may be a lack of publicity--not too many people understand XHTML 1.0. Even if you have heard of it, you may not be aware of it: how easy it is to use it now.

    Another reason is that the current software tools for HTML development (such as Adobe golive, Macromedia Dreamweaver, Microsoft FrontPage, and so on) do not support XTHML, and many of those who love these tools or must use them in their work Web authors worry about this.

    However, despite these difficulties, XHTML 1.0 is moving forward. In fact, the next version, XHTML 1.1, is fairly well developed and contains some new, different concepts for Web tag authors. Modularity (partitioning languages into separate modules) is a major part of XHTML 1.1. Moreover, more XML-like advantages are playing a role. For example, the ability to write your own DTD for XHTML documents or to use schemas (schemas) will bring true scalability.

    XHTML 1.0 is today's Web markup standard. If you haven't used it yet, you should at least have a good try. Advances in the field of XML-related technology (especially in the wireless field) strongly and convincingly show that the more flexible the author of a markup language is, the more promising it will be. XHTML 1.0 is an excellent way to broaden your horizons. It makes sense to be familiar, powerful enough to help you create a stable, interoperable Web site that is ready for today's and exciting opportunities for tomorrow.

    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.