What is XHTML?? _ Experience Exchange

Source: Internet
Author: User
Tags closing tag tidy
Objective:
Now we all pay attention to the standard construction 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 convert? 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 best to learn HTML first, because it is relatively simple, and then look at the tutorial. It is also a continuation of the Web Standard XHTML&CSS I have published.

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 a different name. In fact, we say that the standard should be XML, then why learn XHTML? Because now the HTML code cumbersome, dangerous, but the XML use of the environment is not mature, so the introduction of an excessive product is XHTML, it plays the role of the next. Some people think that XHTML is an upgrade version of HTML, in fact, is also correct, my understanding is XHTML to make HTML more standardized markup language, make HTML become powerful, reduce the code cumbersome, especially the table.
XHTML was established on January 26, 2000 by the International Organization for Standardization (World Wide Web Consortium) as a standard, considered to be one of the latest versions of HTML, and will gradually replace HTML. All browsers now support xhtml,xhtml-compatible HTML 4.0. Some people think that XHTML is HTML4.01. If you have written a standard station yourself during the learning process, you can verify through the website, you will get a logo after verification, usually XHTML1.0 authentication and CSS validation. I also do not know how many sites in the country at the same time through the two verification. We can go to http://www.w3.org/this site to verify your station, if the two rules will be the two pieces of code added to your page to show others that you used the standard station AH, cow Ah!

Why we use XHTML
XHTML is an over-product of HTML upgrade to XML and is set as a standard, XHTML is fully compatible with HTML4.01, and has XML syntax. Let's look at an HTML with an error code, as follows:

  
   <title>This is the bad HTML</title>
  
  

Bad HTML
  
The error code is included, but it will be displayed when we browse in the browser. XML is a markup language, but it requires that any element that appears in the Web page should be flagged, and that XML is used to describe the data in the Web page, and that HTML is used to display the elements in the page. At present, we use a variety of Internet browser technology, including laptops, mobile internet browsing and so on, are required to browse some of the content must be correctly labeled, if there is a wrong mark may make the display particularly confusing, even not normal display.
So with the combination of HTML and XML, and some other techniques, we've got a language-XHTML that is now useful and useful in the future.
When we are going to standardize in the future, we need to use the XHTML correct format tag, so that all browsers can execute correctly, so it is now necessary for us to start learning XHTML.

The difference between XHTML and HTML:
XHTML is a new technology that we should be familiar with before the browser and some other software support it. We should be familiar with HTML4.0 before we learn XHTML better, we can download a reference manual to familiarize yourself with it. To make it easier for us to learn XHTML, in other words, we should try to write code less error code when we use HTML, such as: all lowercase characters to write HTML, after each tag to add the end of the tag as follows:

Web Teaching Network welcome you

The end must have, we have to keep this rule.
The biggest difference between them is:
The 1.XHTML element must be properly nested.
In HTML, some elements can be incorrectly nested and can be displayed normally, such as:
   This text is bold and italic
The XHTML must be properly nested before it can be used normally, such as:
   This text is bold and italic
Note: This error usually occurs in tags after nesting multiple layers. Such as:
  

         
    • Coffee

    •    
    • Tea
         

            
      • Black Tea

      •     
      • Green Tea

      •    

         
    • Milk

    •   

The correct one should be:
  

         
    • Coffee

    •    
    • Tea
         

            
      • Black Tea

      •     
      • Green Tea

      •    

         

    •    
    • Milk

    •   

Observing the above two-segment code we can see right inside of us inAfter insertingLabel.
XHTML files must have the correct organizational format.
All XHTML should be properly nested in theStart withThe end of the element, the other elements can have child elements, and the child elements are also properly nested within their parent element. Such as:

   ...
   ...
  
Label names must be in lowercase letters.
Because XHTML documents are XML applications, XML is sensitive to capitalization. Like
And
is a two different tag. such as the error code:
  
  

This is a paragraph


  
The correct format is:
  
  

This is a paragraph


  
All XHTML elements must be closed
Can not have no closed empty elements exist in our code, in fact, for this we are relatively good end, there should be the beginning of the end? For example, the error code:
  

This is a paragraph
  

This is another paragraph
The correct is:
  

This is a paragraph


  

This is another paragraph


A separate label we're going to end up with/>.
Example: Error code
This was a break

Here comes a horizontal rule:
Here's an image
Correct code:
This was a break

Here comes a horizontal rule:
Here's an image
We basically see the difference between HTML and XHTML through the above examples, so we should try to change our current HTML from now on, for example, we use lowercase tags, and the symbol/> with the closing tag after the tag.

The syntax of XHTML
Simply write XHTML with clean HTML syntax.
Some of the other syntax requirements for XHTML are:
Attribute names must be lowercase. Such as:
Error code:
  

The correct code:



The property value must be referenced. such as: The Wrong code:


The correct code:




  
  
  
  
  
The correct code:
  

  
  
  
  
  
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 attribute with the id attribute. Such as:
In HTML 4.01, a name attribute is defined for A,applet, frame, iframe, IMG, and map. In XHTML, the name attribute cannot be used, and it should be replaced with an ID. Such as:
Error code:
  
The correct code:
  
Note: We can also use both the ID and the Name property in the tag in order for the old browser to be able to execute the content normally. Such as:
  
In order to adapt to the new browser browse our above code in the end I added/to end the tag.

The XHTML DTD defines the type of document.
In XHTML we have to declare the type of document so that the browser knows what type of document you have, and the declaration part is added to the head of the document. Such as:
  
  
  
   <title>Title goes here</title>
  
Body text goes here
  
Note: The DOCTYPE declaration is not part of the XHTML document, nor is it an element of the document, so we do not need to add an end tag.
Note: XHTML attributes are all in theTag inside. However, when we verify in w3.org, we do not explain whether our document has a claim type. This is because "xmlns=http://www.w3.org/1999/xhtml" is a fixed value, and if you do not declare it, it will be automatically added to theBefore the label.
The basic body we use when using DOCTYPE:
  
  
  
   <title>...</title>
  
   ...
  
DOCTYPE is a shorthand for document type, which is used to describe what version of XHTML or HTML you are using.
The DTD (for example, XHTML1-TRANSITIONAL.DTD) is called the document type definition, which contains the rules of the document, and the browser interprets the identity of your page according to your defined DTD and shows it.
The DOCTYPE statement is an essential part of establishing a standard-compliant web page, and your logo and CSS will not take effect unless your XHTML determines the correct doctype.

XHTML 1.0 provides three types of DTD declarations to choose from:

Transition (Transitional): A very liberal DTD that allows you to continue to use HTML4.01 's identity (but to conform to XHTML notation). The complete code is as follows:

Strict (Strict): Requires strict DTD, you cannot use any of the presentation layer's identity and attributes, the complete code is as follows:

Framework (Frameset): A DTD used specifically for frame page design, if your page contains frames, you need to use this DTD. The complete code is as follows:


How to convert an existing structure to XHTML
What kind of doctype do we choose? The ideal scenario is of course a strict DTD, but for most of us who are new to Web standards, the transition DTD (XHTML 1.0 Transitional) is the ideal choice (including this site, which is also a transitional DTD). Because this DTD also allows us to use the identity, elements and attributes of the presentation layer, it is also easier to pass the code validation.
Let's take a look at the following points from the current HTML conversion to XHTML:
First, the document type description is added to the header of each page. Such as:
Of course you can choose other types of.
Both the tag and name are in lowercase.
All attribute values are quoted in quotation marks.
Iv. a separate label, such as:,
And, to the end of the Add/come at the back.
In this case, it is not recommended to use a method such as: and form, directly behind the Add/on, as

Five, through the certification. Go to the official website of the Web site: http://validator.w3.org/check/referer, the error will be displayed when verifying. You can also use the tool tidy available on the official website to achieve the conversion: http://www.w3.org/People/Raggett/tidy/

The modularity of XHTML
Why Modular design XHTML? Although XHTML is simple, it has a lot of content, including most of the features a web designer needs. XHTML is complex on the one hand, but it is very simple from another point of view. In order to divide XHTML into smaller modules, the consortium has built a small set of XHTML elements that have been defined, and are used independently by simple devices that can be combined into larger, more complex programs with other XML standards.

Through the XHTML model, the programmer can do the following things:

1. Select the elements supported by devices that can be used by the XHTML building blocks standard.
2. Using XML while adhering to the XHTML standard can be extended to XHTML.
3. Simplistic XHTML can be applied to devices like handheld computers, mobile phones, televisions and home appliances.
4. Add XHTML to the design of complex programs by joining the XML functions of the heart (like Sound, multimedia).
5. Define XHTML outlines like XHTML Basics (XHTML is a subset of mobile devices).


* Indicates disapproval is applied to XHTML
  • The abbreviation for the attribute is forbidden. such as: The Wrong code:

    Related Article

    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.