Home > Web Front-end > H5 Tutorial > body text

The difference between HTML5 and XHTML2

PHPz
Release: 2018-10-12 17:07:18
Original
1613 people have browsed it


Most people use HTML 4 and XHTML 1 to write web pages. Relatively few HTML enthusiasts understand the concepts of semantic HTML, validating HTML structure, and improving document accessibility. High-quality HTML documents are the result of repeated trade-offs, design optimizations, and discussions. Despite all the criticism, no language has ever matched the popularity of HTML. Most users are content with the status quo of standards, as if they were born that way.
But like many other standards, HTML has successors. Even now, experts are still thinking about the next version of HTML, fixing all the known problems in the current version. As with any crowd, these experts disagree about the future direction of this work.
The first proposal for a new HTML version came from a working group within the W3C organization. The working group's ideas revolve around XHTML 2, a standard that continues the original development direction of further purifying XHTML and returning to the design concepts of the first version of HTML.
Some important HTML experts outside the W3C — browser vendors, web developers, authors, and others — disagree with the direction of XHTML 2. In 2004, they formed an independent working group to propose a new design direction for the new HTML version. Under the name WHATWG (Web Hypertext Application Technology Working Group), they launched HTML 5 and Web Forms 2.
A few years later, an alternative direction for HTML was clearly described in a working draft. In April 2007, the W3C voted on whether to admit HTML 5 to the standards review process, without recognizing it as an official standard (yet). Most people agree. An interesting situation arises: the W3C is simultaneously working on two competing successor technologies to HTML and XHTML. In theory, there are good reasons for both. Practically speaking, there are many hurdles to overcome in getting all major browsers to support both standards.
This is the basic fact that led to the current situation. It would be more meaningful to discuss the real differences between the two proposals. This article outlines the basics of both proposals and then analyzes the design concepts behind them. Frequently used abbreviations
CSS: Cascading Style Sheets
HTML: Hypertext Markup Language
W3C: World Wide Web Consortium
XHTML: Extensible Hypertext Markup Language A brief history of XHTML
Understanding the design philosophy behind XHTML 2 requires a little history. In the early 1990s, the first versions of HTML were based on Standard Generalized Markup Language (SGML). The main difference is the hyperlink property - a key foundation and success factor of the World Wide Web. Like SGML, HTML allows authors to describe the structure of a document, separating headers from paragraphs, ordered lists, and unordered lists. The results displayed on the screen depend on the browser.
As the Web becomes more popular, HTML users demand control over the look and feel of their pages. Browser vendors introduced new features in HTML 2 and 3. Web pages become difficult to understand, and complex nested table structures become the main means of controlling page layout. The rest of the document is filled with font tags and color declarations. The original document structure has become difficult to sort out.
HTML 4 emerged to end this confusion, pushing presentation logic to CSS and introducing layers (DIVs) for advanced content positioning. This means a change in code writing model compared to HTML 3. To simplify the migration process, older HTML 3 structures are supported through the Transitional version of HTML 4. The Strict version for advanced users requires a clean separation of content and presentation.
The first HTML 4 websites used DIVs like the new Holy Grail, using them on almost every element on the page that needed a little polish, including (but not limited to) the header. HTML style attributes are a common place to describe presentation details. Finally eliminated the cluttered tables from the web. But content and presentation logic are still mixed together. The essential CSS file is only a few lines long.
Recently, some well-known web developers have come up with a more clever approach to HTML 4 stylesheets. In modern browsers, CSS properties are not limited to DIV elements. You can specify styles for any HTML element if you wish. A lot of weblogs started talking about Semantic HTML. There is no outright ban on the DIV element, but web page writers are starting to use HTML elements that best describe their content. For example, most website navigation menus are best described as unordered lists. As another example, instead of using a class name like bigHeader for paragraph elements, use H1 elements instead, and then use CSS to modify the representation as required.
Meanwhile, the W3C proposed XHTML 1 as a version of XML that conforms to well-formed and valid HTML 4. For XML users, this simplifies the task of converting XML content into web pages and checking the conversion results against existing validators. XHTML 1.1 attempts to isolate different problems into different modules. A modular approach makes it easy to reuse different parts of the standard for different needs and to extend the standard with new functionality.
XHTML 1.1, which has even more users than HTML 4, separates content from presentation. But as in the past, some practical problems can only be solved using tricks in CSS. For example, menu structures represented by unordered lists often include beautiful images. However, images are not easily read to visually impaired people through text-to-speech facilities. And text browsers like Lynx can't display images. A complex CSS trick can hide text and display an image in the browser. But if the menu is different on different pages, it will be difficult to specify this part with CSS. The design philosophy behind XHTML 2
The most important design philosophy behind XHTML 2 is to further separate content and presentation and improve the remaining flaws of HTML 4 and XHTML 1. For example, native support for specifying images for each item in an unordered list. The original IMG SRC tag is replaced by the optional SRC attribute that can be used on any element. The modified CSS is completely divorced from content, and devices that don't support images can easily represent text instead.
But CSS isn’t the only challenge for web developers. A lot of time is spent interacting with the server and HTML forms and there is a lot of JavaScript™ code. Forms are limited to one-dimensional key-value pairs. It's a lot of work to develop JavaScript code, but it's useless on an interface like a text-to-speech device.
Based on a modular approach, XHTML 2 replaces HTML Forms with XForms modules, adding support for common problems using the appropriate application model. XForms can specify interaction logic, validation rules, and calculation methods without a single line of script. Additionally, this technique uses a rich XML structure rather than key-value pairs, allowing for nested subforms and repeated elements. In addition to providing a powerful engine, text-to-speech devices are better suited for changing the richness of applications.
In addition to XForms, there are other XHTML-related issues extracted into independent specifications to meet other needs - such as XML Events, XFrames and Ruby (Asian languages).
With the separation of representation, programming is also separated from the standard. Interaction properties like onClick are replaced by the XML Events module. Because the XML Events specification itself was designed for this purpose, it provides a more powerful set of tools for working with user interfaces.
For the innovation of XHTML 2, in summary, the basic idea is to break down different problems. The issue ceases to be a secondary feature of HTML and becomes the primary purpose of the new specification. Therefore, the new specification is best suited to the problem faced by the optimization. However, treating different issues differently is a matter of philosophy rather than practice. Smart developers who are familiar with using this set of tools can get the results they need. However, it is not easy to say whether the average user of the current HTML version can create high-quality XHTML documents.
XHTML 2 is probably not targeted at general HTML users. But in the hands of a good developer, it can be a great way to enhance accessibility. HTML 5 design philosophy
WHATWG adopted a more realistic approach when designing HTML 5. Without considering abstract concepts such as problem decomposition, this working group developed documents based on the behavior of current mainstream browsers, which is completely different from W3C specifications. Based on the above analysis, this working group investigated the practical use of HTML.
Based on this information, the working group proposed initiatives aimed at simplifying the work of the average web developer. Although HTML 5 claims to be derived from the previous version of HTML, its primary goal is not purity. For example, the main goal of modular documentation is to facilitate replacement with optimized web applications.
Modular languages ​​based on this purpose greatly simplify the development of web applications. For example, HTML 5 supports interactive components such as data tables, menus, and toolbars. Using descriptive HTML elements with default behavior avoids having to write a lot of code to simulate the behavior of a generic DIV.
HTML 5 specifications are not limited to HTML elements and attributes. It defines specialized JavaScript APIs for document editing and drag-and-drop interactions. This approach is completely different from decomposing the problem. It simplifies the web developer API but increases the size of the specification.
HTML 5 is much more similar to HTML 4 than XHTML 2 is to XHTML 1. The migration path is flatter and it's easier for experienced HTML 4 developers to become familiar with the new version. New features follow a similar logic. Specialized event attributes for specific elements allow HTML editors to provide more appropriate text completion functionality.
Current web applications rely on asynchronous JavaScript XML (Ajax) to interact with servers. HTML 5 recognizes the importance of interacting with the server and defines a variety of ways to interact with the network, distribute received server events, and send messages to documents from other domains without creating security issues.
The basic design philosophy of HTML 5 is to extend HTML 4 with features that web developers need. HTML 5 inherits the basic technologies of HTML 4 while simplifying them. In order to solve the shortcomings of HTML V4, HTML V5 chooses the simplest and most direct way to redesign. Practical application of new standards
XHTML V2 and related modules are officially supported by the W3C, and related modules become an important factor in other XML specifications supported by the W3C. Unfortunately, official endorsement by the W3C does not guarantee support in major web browsers. Support for XHTML V2 in general is not a problem: modern browsers already support many features. Correct use of XHTML V2 depends on the availability of relevant modules. At the time of this writing, it is unclear whether Microsoft will extend Windows® Internet Explorer® to support XML Events and XForms features. A Mozilla XForms plug-in, including XML Events, has been in development for several years. This plug-in improves the functionality of this technology and reduces the difficulty of implementation.
The writing of the HTML V5 specification maintained in-depth communication with browser manufacturers and always took implementation issues into consideration. Although the team expressed doubts about official W3C endorsement. The FAQ doesn't even officially answer the question of when official approval will come through. Regardless of the W3C's stance, browser vendors appear to have decided to implement the unofficial HTML 5 standard. This is not the first time that browser manufacturers have rushed ahead of the release of official standards. Competing standards
As of now, neither HTML 5 nor XHTML 2 are official recommendations. Some minor details may change in the future. But their development direction will not change, and both have solved some shortcomings of the current standards. It remains to be seen how future browsers will add support for these two new standards. Current browsers support both HTML 4 and XHTML 1. Similarly, future browsers may support both HTML 5 and XHTML 2. Both standards have their proponents.
If you are more concerned about XHTML 1.1 than HTML 4 and want to create documents that can support different devices, you may prefer XHTML 2. If you are using XHTML 1 simply because it conforms to the XML standard and prefer the new features of HTML 5, XHTML 5 (HTML 5 rewritten in XML) may be your best choice.
HTML 5 is popular with developers who use HTML 4 to create interactive web applications. This approach is more feasible for sites using a WYSIWYG document editor. But on a case-by-case basis, HTML 4 and XHTML 1 are likely to coexist for a long time.                  

For more related tutorials, please visit Html5 video tutorial

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!