Back in the past for a little over ten years, December 18, 1997. Internet Explorer 4 was released 3 months ago, The Mozilla Foundation has not yet been formed, and Firefox is still far away. There is no XMLHttpRequest, not even XML. On this day, more than a decade ago, HTML 4.0 was published as a W3C recommendation.
It became the basis on which modern web standards were developed. Of course, there were improvements. In 2000, XHTML 1.0 was adopted as the official recommendation, and CSS 2 was implemented by most browser manufacturers. But the basis of the Web - the backbone on which each site is built, from simple business cards to complex applications - essentially remained unchanged.
At least until today. After a long lull, it seems, the way things are changing at W3C is that two competing specifications are under development to replace outdated HTML 4.x and XHTML 1.x standards. Both initiatives are working under the auspices of the W3C (even if this was not always the case), and both, in my opinion, are far superior to the current selection of web markup languages. These are HTML 5 and XHTML 2.0 . And if you are reading this article, you will most likely have to work with one (or both) of them over the next few years.
')
Work on XHTML 2.0 began soon after the publication of XHTML 1.1 as a recommendation in 2001. The first draft of XHTML 2.0 was published in 2002, but much of the document was in a non-normative and unfinished state (and there is still something left). By 2004, some prominent industry figures — browser developers, designers, web developers, and content owners — had increased dissatisfaction with the management of the XHTML 2.0 working group . Recalling the closed nature of the work of the W3C, they decided to establish and develop their own standard.
So, in 2004, an independent coalition was formed, called the WHATWG (Web Hypertext Application Technology Working Group). The group began work on a specification called Web Applications 1.0. In April 2007, the W3C voted in favor of the proposal to consider the group specification. The WHATWG members started working as part of the W3C as an HTML team and continued working on their project, which was renamed HTML 5. Thus, the HTML 5 draft should one day become a W3C recommendation along with XHTML 2.0 (although this day is still very long already missed several key stages of the project ).
XHTML 2.0 is completely XML based, developers have abandoned the SGML legacy and syntactic features found in the current web markup. It is positioned as a “general purpose language”, with minimal default functionality that can be easily extended using CSS or other technologies (XForms, XML Events, etc.). This modular mechanism allows the XHTML 2 development team to focus on the overall layout of the document while others are developing mechanisms for presentation, interactivity, document construction, etc.
The first priority for the XHTML 2 working group is to further separate the content and structure of the document from its presentation. Other goals are increased convenience and accessibility, improved internationalization, greater device independence, fewer scripts, and integration with the Semantic Web. Developers were less interested in backward compatibility than their predecessors (and the HTML team), which led to the removal of some syntactic baggage that existed in early incarnations of HTML. The result was a cleaner and more concise language, correcting many of the old flaws in Web markup.
While the concept of XHTML 2.0 is intended to be revolutionary, the HTML team chooses a pragmatic approach and creates HTML 5 as an evolving technology. It turns out that HTML 5 is a step forward, but is still mostly compatible with current HTML 4 / XHTML 1 standards. However, HTML 5 offers many changes and extensions to HTML 4 / XHTML 1 , pointing out many of the shortcomings of its previous specifications.
The HTML 5 specification is about moving HTML away from the markup of a document and embedding it in languages ​​to create web applications. To this end, the focus is on creating a more reliable and functional client environment that provides various APIs for developing web applications. Among other things, the specification stipulates that implementations must provide client-side persistent data stores (of both key / value type and SQL databases), an API for playing audio and video, 2D drawing through a canvas element, message exchange between documents , events sent by the server and network APIs.
HTML 5 supports SGML-like syntax that is compatible with current HTML specifications (although some of the more esoteric features of SGML are no longer supported ). The specification also includes a secondary "XML serialization", which allows developers to use the correct XML documents. By preserving SGML-like serialization, the HTML 5 team has achieved a balance between pragmatism and progress: developers can choose between markup using HTML serialization (which is more like HTML 4.x) or XML serialization (more like XHTML 1.x) .
It would not surprise anyone that both development teams offer a number of similar capabilities. They point to the well-known "sore spots" of web development and will be a welcome addition to the new generation of markup languages.
A number of elements will be deleted in XHTML 2 and HTML 5, as they are responsible only for the presentation of the document. It is believed that the presentation should be managed through style sheets.
XHTML 2 and HTML 5 documents cannot contain the following elements: basefont
, big
, font
, s
, strike
, tt
and u
. XHTML 2.0 also removes the small
, b
, i
and hr
elements, and HTML 5 overrides them with a different value (not responsible for the presentation). In XHTML 2.0, the hr
element is replaced by the separator
element in order to reduce confusion (the hr
element is intended to create horizontal separators, but is not necessarily used for this).
Navigation lists were introduced in both XHTML 2.0 and HTML 5. In XHTML 2.0, they are defined by the new nl
(Navigation List) nl
. The list itself must begin with a child label
element that defines the list header. After it can go one or more li
elements used to mark up links. Also new in XHTML 2.0 is the ability to create links from any element using the href
attribute for it. The combination of these methods allows you to create simple, easy menu markup:
<nl> <label> Category </ label> <li href = "/"> All </ li> <li href = "/ news"> News </ li> <li href = "/ videos"> Videos </ li> <li href = "/ images"> Images </ li> </ nl>
In HTML 5, the nav
was introduced for this purpose. Unfortunately, nav
not a list element, so it cannot contain li
children for the logical organization of links (perhaps a new idiom will be developed). And since the a elements are still necessary for creating links in HTML 5, the navigation markup is not very elegant:
<nav> <h1> Category </ h1> <ul> <li> <a href="/"> All </a> </ li> <li> <a href="/news"> News </a> </ li> <li> <a href="/videos"> Videos </a> </ li> <li> <a href="/images"> Images </a> </ li> </ ul> </ nav>
Both specifications contain new features for creating more consistent forms using fewer scripts. In XHTML 2.0, the HTML form standard has been completely removed in favor of the broader XForms standard. The XHTML 2.0 development team does not control this technology, but only refers to it in the specification. To simplify reuse in XForms, the data collected is separated from the layout of controls. It is a powerful language, but its full description is beyond the scope of this article. Suffice it to say that even a small knowledge of this technology will significantly increase the speed of development.
HTML 5 retains the usual HTML forms, but adds some data types to simplify development and increase user convenience. Added several new input element types for email addresses, URLs, dates and times, and numeric data. This will allow browsers to create a more convenient user interface (for example, dialogs to select dates and times), integrate with other applications (select addresses from Outlook or Address Book, for example) and validate user input before sending to the server (shortening JavaScript checks on the side customer).
Both specifications cover the approaching Semantic Web , allowing developers to embed more rich metadata into documents. As with forms, the XHTML2 development team uses more sophisticated technology, while the HTML 5 developers have taken a simpler path.
In XHTML 2.0, metadata can be embedded using several new attributes from the Metainformation Attributes Module . In particular, the new global role
attribute is intended to describe the value of this element in the context of the document. The technology also uses Embedded Structured Data into Web Pages ( Embedding Structured Data in Web Pages ) technology, for which the group uses existing standards, referring to RDF . This technology is extremely powerful, but also complex.
The HTML team chose an approach that is very similar to microformats — overloading the class
attribute with a predefined set of classes representing different data types. At the moment there are seven reserved classes in the specification: copyright
, error
, example
, issue
, note
, search
and warning
. Although this method may not seem very reliable, it is unlikely that these elements will appear differently in different browsers. The class names are quite specific, so there is a lot to worry about: an element with a copyright
class will be displayed as copyright, regardless of whether the developer knew about the reserved classes or not.
The following are some of the features of HTML 5 that are unparalleled in XHTML 2.0.
HTML 5 introduces a series of APIs that significantly improve the shell for client-side development. They make HTML 5 a stack of technologies for web applications, and not just a language for markup of documents. It is worth noting that the details of these APIs are now worked out by the Web API working group (Web API working group), so they can be taken with the rest of HTML 5 or independently. New APIs and related elements are:
canvas
audio
and video
elements.contenteditable
.draggable
attributeevent-source
element.HTML 5 introduces a number of new features not found in XHTML 2.0:
figure
represents an image or a graph with a title. The legend
nested element displays the title, and the usual img
element is used for the image.m
displays text selected in some way. It can be used to highlight words when displaying search results, for example.time
displays the date and timemeter
displays measurements or quantitiesdatagrid
displays interactive data tree or tabular datacommand
displays a command that a user can execute.event-source
used to catch the events sent by the serveroutput
displays a specific output type, such as the result of the script calculation.progress
— displays the progress
process, such as loading or executing a series of laborious calculations.In addition, some new elements help semantically mark up parts of a document. Their names speak for themselves: section
, article
, header
, footer
and aside
. A new dialog
element is designed to display messages using child elements: dt
is for the sender's name, and dd
is for the text of the message.
The new ping
attribute can be used in the a
and area
elements to track users. This attribute allows you to specify a space-separated list of URIs that should be notified when following a link; this allows you to avoid using redirects or JavaScript.
New features that are only available in XHTML 2.0
In XHTML 2.0, the href
attribute can be specified in any element, thereby turning it into a link. With this change, the element a
no longer necessary, but it remains.
In XHML 2.0, the img
element has been removed. But do not worry - now any element can be an image. The idea is that all images have a long description that is equivalent to the image itself. By adding the src
attribute to any element, we tell the browser to load the specified resource and place it in place of the element. If for any reason the resource is unavailable, the content of the item will be displayed. This allows developers to provide several equivalent resources using different file formats and views by nesting the elements into each other.
The honorable br
element, used to insert a newline, was also removed in XHTML 2.0. To replace it, introduced a new element l
. It represents a string of text, and works like a span
, after which br
according to the rules of the current markup.
New elements h
and section
were introduced to replace the numbered elements h1
- h6
. The purpose of this is to convey the hierarchical structure of the document Current numbered headers are linear, not nested. When nesting section
and h
elements in the parent section
structure of the document will be clear.
The XHTML 2 development team focused on creating a more general, simplified language. In view of this, they refrained from adding a variety of specialized elements to represent various types of content. They argue that the new role
attribute provides a mechanism for implementing rich metadata that makes specialized elements unnecessary. Nevertheless, several new elements were included:
blockcode
represents computer codedi
represents a group of related terms and definitions in dl
(definition list). This is convenient for words with different meanings or different pronunciation.handler
represents a script event handler with a type
attribute that indicates the handler language. If the browser does not understand it, the children of the handler element are processed (otherwise they are ignored). Thus, handlers can nest each other to provide implementations in multiple languages.Both proposals look promising and contain many new features that point to common web development problems. But no specification is the official recommendation, and so, most likely, will be for some time.
Despite a late start, the HTML 5 team has a lot of industrial support and has come a long way in the recommendation process. Their goal is to have a complete specification, with many interoperable implementations no later than 2010 (as I said, despite this, the W3C consortium already missed several steps in the approval process). With the industrial support of most major browser developers (the only exception is Microsoft), these specifications are most likely to be implemented quickly and consistently as soon as they reach a stable state.
Universal desire is to avoid another war of standards. Fortunately, since both languages ​​support XML namespaces (or, in the case of HTML serialization in HTML 5, a DOCTYPE switch), it is unlikely that we will see the same dependence of displaying a document on a browser as observed in the 90s. If you sweep aside the war of standards, the future of web development looks bright. These new markup features and APIs provide a good wrapper for web development, which should bridge the gap between desktop and web applications.
Original: Mike Malone, XHTML 2 vs. HTML 5
Translation: Helios
Source: https://habr.com/ru/post/31582/