Difference between HTML and XHTML. What is XHTML? Errors in XHTML and differences between XHTML and HTML What is xhtml

The article is based on the original W3C document - XHTML™ 1.1 - Module-based XHTML - Second Edition: W3C Working Draft 16 February 2007. It may change, but will likely replace the existing recommendation - XHTML™ 1.1 - Module-based XHTML.

Strict compliance of documents

Documents that are fully compliant with XHTML 1.1 must meet the following criteria:

  1. The root element of the document must be the element .
  2. Document root element ( ) must point to an XHTML namespace using the xmlns attribute. The namespace indicator for XHTML is "http://www.w3.org/1999/xhtml", that is, the opening html tag should be a construct like: .
  3. The root element may also contain a schemaLocation attribute. The schemaLocation attribute for XHTML is defined as: "http://www.w3.org/MarkUp/SCHEMA/xhtml11.xsd" .
  4. There must be a DOCTYPE document type declaration preceding the root element. The identifier included in the DOCTYPE declaration must point to the corresponding DTD. This identifier might look like this:

Here is an example of a document that complies with XHTML 1.1:

Virtual Library

Moved to example.org.



Note that in this example, an XML declaration is included. An XML declaration like the one above is not required in all XML documents. Authors of XHTML documents are highly encouraged to use the XML declaration in all of their documents. This declaration is required when the XML document's encoding is other than UTF-8 or UTF-16.

XHTML 1.1 documents should specify the document content type as either text/html or application/xhtml+xml.

Naturally, user agents (for example, browsers) for their part should also take these recommendations into account.

XHTML 1.1 document type

XHTML 1.1 is a fully functional document type with advanced semantics. However, it is not as functionally diverse as the XHTML 1.0 Transitional or XHTML 1.0 Frameset types. Beginning with XHTML 1.1, the document type does not contain deprecated elements contained in XHTML 1.0 or HTML 4 types. Despite these exceptions, or perhaps because of them, the XHTML 1.1 type provides a solid basis for creating new document types in the future, with full support from various agents users.

The XHTML 1.1 type is composed of the following XHTML modules.

Structural module body, head, html, title Module for working with text abbr, acronym, address, blockquote, br, cite, code, dfn, div, em, h1, h2, h3, h4, h5, h6, kbd, p, pre, q, samp, span, strong, var Hypertext module a List module dl, dt, dd, ol, ul, li Object module object, param Module of various presentation methods b, big, hr, i, small, sub, sup, tt Editing module del, ins Bidirectional text support module bdo Form module button, fieldset, form, input, label, legend, select, optgroup, option, textarea Table module caption, col, colgroup, table, tbody, td, tfoot, th, thead, tr Image module img Client side image map module area, map Server side image map module ismap attribute included in img Internal events module Event attributes Meta information module meta Script module noscript, script Style sheet module style Style attribute module (Deprecated) Style attribute Link module link Base module base

XHTML also uses the Ruby Annotation module:

Ruby Annotation module ruby, rbc, rtc, rb, rt, rp

The names of the modules in the list are given according to their definitions in the current version of XHTML Modularization. For more information about modules, see the XHTML Modularization document.

Differences from XHTML 1.0 Strict

XHTML 1.1 differs from both HTML 4 and XHTML 1.0 technologies. The most significant is the elimination of obsolete elements. In general, there is a strategy to define a markup language from a structural and functional perspective, regardless of the style sheets used for document design.

The differences can be formulated as follows:

  1. The lang attribute has been replaced with the xml:lang attribute.
  2. In the a and map elements, the name attribute is replaced by the id attribute.
  3. The collection of Ruby elements has been expanded.

Thus, the XHTML 1.1 type is not very different from XHTML 1.0 Strict, however, these differences are quite significant and must be taken into account.

XHTML(from English Extensible Hypertext Markup Language- modular hypertext markup language) - an extensible family of all languages ​​and page markup modules based on XML, only with expansion and repetition of capabilities HTML 4.

XHTML versions

XHTML 1.0 approved by the World Wide Web Consortium on January 26, 2000. Already on August 1, 2002, the second revised edition of the specification was published.

XHTML 1.0(similar to HTML 4) consists of three types of documents:

  1. XHTML-1.0-Strict- allows you to exclude the full use of elements and attributes that define graphic display in the form of elements font or attribute bgcolor. Refers to the most preferred document type.
  2. XHTML-1.0-Transitional- allows the use of any elements and attributes with graphic display, but these elements are recommended for use only in cases of extreme necessity. As an option - to make it as easy as possible to migrate documents from HTML 3.2 on XHTML.
  3. XHTML-1.0-Frameset- adds to the capabilities of the second document type ( XHTML-1.0-Transitional) also the use of frames.

XHTML 1.1- a version containing XHTML 1.1 Modular, in which authors are allowed to import any additional properties into the markup.

For XHTML Basic And XHTML MP characteristic:

  • XHTML Basic, which, due to a special lightweight version of XHTML, cannot use full sets of XHTML elements. As a rule, it is used for miniature devices, such as, for example, mobile phones.
  • Mobile profile XHTML based on XHTML Basic, but with the addition of specific elements.

XHTML 2.0

The latest version of XHTML that never reached full recommendation status. The activities of the developers of this version were stopped at the end of 2010, and all resources were combined into a common working group HTML 5. The results of the developments in December 2010 were published in the form of a report of the working group.

Disadvantages of XHTML

A review of all sources and the work experience of professionals makes it possible to collect all the reasons why the use of XHTML can be called inappropriate. The main impetus for identifying these reasons came from a review XTML 5. He identified 12 reasons why it is not recommended to use XHTML. 4. HTML is a more optimized markup for any search engines, compared to XHTML, because less code is written in it. 5. For people interested in current copyright protection, it is much more difficult for people to parse HTML - automatically copy it, since XHTML is designed for maximum ease of parsing. 6. Guaranteed reliability when automatically copying an XML document. This is evidenced by the fact that the work is completed if an error is found. 7. Internet Explorer versions 6 and 7 are not supported application/xhtml+xml. 8. Most HTML documents are not indexed by many search engines in the same way as XML. 9. Layout of HTML is much more convenient, easier, and simpler. 10. XHTML Document.write scripts do not work, only simple correspondence using DOM functions. 11. When using DOM functions, you need to omit all element names to lowercase. The same procedure must be followed for selectors in styles. 12. XHTML format does not support functional programs document.body, document.images And document.forms. 13. It is impossible to keep all elements in the same form, since any “>” sign can disrupt the finished structure. And if you escape it with “>” or by enclosing it in CDATA blocks, you can break HTML browsers. 14. Not the reality of automatic background color propagation body in XHTML for the entire window. 15. Waiting for a new improved and more popular standard HTML 5, with the help of which the studied HTML 4-format.

When choosing DOCTYPE It is necessary to clearly decide which of the two standards to choose: HTML or XHTML. And to make your choice easier, I decided to disassemble difference between HTML and XHTML.

Main difference between HTML and XHTML is that XHTML based on syntax XML. And, therefore, it is more strict, and one cannot allow in it those liberties that can be allowed in HTML.

Now let’s look at it point by point XHTML syntax features:

1. Every tag must close

Paired tags must be closed in HTML too, but we all know that in HTML there are many single tags (for example,<img>), and we could safely write this way:

However, in XHTML All tags must be closed, even single ones, and they are closed as follows:

The only difference is the slash before the second angle bracket.

2. All special characters must be replaced with entities

That is, you cannot write like this: " & ", you need to write this symbol only with the essence, that is, " & ". IN HTML there is no such rule.

3. All attribute values ​​must be in quotes.

You and I all know that in HTML you can write it like this:

That is, we have the attribute value " width" is without quotes. In XHTML This is unacceptable, and it should be written like this:

4. All tags and attributes must be written in lowercase.

To be honest, I never understood why people write tags in uppercase. In my opinion, this disfigures the code, and it feels like it was written without wrangling" CAPSLOCK". But if in HTML- it's a matter of taste, then XHTML- this is a rule: write only in lower case.

As you can see, the only difference is in the syntax. There are also other minor differences, but we won't talk about them. In other words, the only advantage XHTML- it's easier document parsing. And also XHTML very suitable for lovers of “clean” code. There are no more advantages. All browsers display correctly and HTML, And XHTML. And often browsers XHTML treated as HTML, so for the appearance of serious differences in HTML and XHTML definitely won't happen.

I chose for myself XHTML, because I really like it when the code is “clean” and when it can be easily disassembled into its component parts ( parsing). Yes, and in general I’m used to the strict syntax of other languages, for example, Java, so I’ll still write as valid as possible. What you choose is up to you to decide, but differences between HTML and XHTML You already know.

If you have installed on your computer antivirus program Can scan all files on your computer, as well as each file individually. You can scan any file by right-clicking on the file and selecting the appropriate option to scan the file for viruses.

For example, in this figure it is highlighted file my-file.xhtml, then you need to right-click on this file and select the option in the file menu "scan with AVG". When you select this option, AVG Antivirus will open and scan the file for viruses.


Sometimes an error may occur as a result incorrect software installation, which may be due to a problem encountered during the installation process. This may interfere with your operating system link your XHTML file to the correct application tool, influencing the so-called "file extension associations".

Sometimes simple reinstalling Internet Explorer may solve your problem by properly linking XHTML to Internet Explorer. In other cases, problems with file associations may result from bad software programming developer and you may need to contact the developer for further assistance.


Advice: Try updating Internet Explorer to the latest version to ensure you have the latest patches and updates.


This may seem too obvious, but often The XHTML file itself may be causing the problem. If you received a file via an email attachment or downloaded it from a website and the download process was interrupted (such as a power outage or other reason), the file may become damaged. If possible, try getting a new copy of the XHTML file and try opening it again.


Carefully: A damaged file can cause collateral damage to previous or existing malware on your PC, so it is important to keep your computer running an updated antivirus at all times.


If your XHTML file related to the hardware on your computer to open the file you may need update device drivers associated with this equipment.

This problem usually associated with media file types, which depend on successfully opening the hardware inside the computer, e.g. sound card or video card. For example, if you are trying to open an audio file but cannot open it, you may need to update sound card drivers.


Advice: If when you try to open an XHTML file you receive .SYS file error message, the problem could probably be associated with corrupted or outdated device drivers that need to be updated. This process can be made easier by using driver update software such as DriverDoc.


If the steps do not solve the problem and you are still having problems opening XHTML files, this may be due to lack of available system resources. Some versions of XHTML files may require a significant amount of resources (e.g. memory/RAM, processing power) to properly open on your computer. This problem is quite common if you are using fairly old computer hardware and at the same time a much newer operating system.

This problem can occur when the computer is having difficulty keeping up with a task because the operating system (and other services running in the background) may consume too many resources to open the XHTML file. Try closing all applications on your PC before opening the Extensible Hypertext Markup Language Document. Freeing up all available resources on your computer will provide the best conditions for attempting to open an XHTML file.


If you completed all the steps described above and your XHTML file still won't open, you may need to run equipment update. In most cases, even when using older versions of hardware, the processing power can still be more than sufficient for most user applications (unless you're doing a lot of CPU-intensive work, such as 3D rendering, financial/scientific modeling, or intensive multimedia work) . Thus, it is likely that your computer does not have enough memory(commonly called "RAM" or random access memory) to perform the task of opening a file.

The development of HTML has, in a certain sense, reached a dead end - new tags are no longer needed, since the existing ones are sufficient, and besides, the emphasis of web page development has shifted to styles that expand the capabilities of document design. Naturally, CSS does not replace HTML in any way, but it allows you to use a limited set of tags, and the appearance of elements, their position and various parameters can be specified through styles.

A certain limitation of HTML is that it belongs to formal languages, in the sense that tags and their hierarchical structure are strictly described in the specification. Therefore, XML is gaining popularity, with which you can create your own tags and form their structure. The difference between HTML and XML is not only the tags, but also the rules for writing code. When working with HTML, the browser “turns a blind eye” to various minor flaws and shortcomings in the structure or to the fact that an attribute is not specified correctly. Such tricks do not work with XML, so the browser will generate an error stating that the document is not formed correctly.

To teach developers the "right" way of thinking, change their coding style, and bridge the gap between HTML and XML, XHTML was developed as an intermediate step between the two.

XHTML (EXtensible HyperText Markup Language) is intended to replace HTML and is considered its more strict version. In general, W3C defines XHTML as the latest version of HTML, which will gradually replace it. Whether this will actually be the case, only time will tell.

If we think of some ideal web page code, it can be compared to a program that will not compile until all errors are corrected. The browser acts as a compiler and does not display the document if it does not meet the specification. XHTML, while retaining all the features of HTML, introduces more strict rules for creating pages in order to get closer to the “ideal” code. This allows you to make sites independent of the display device and browser. In other words, the site will be displayed correctly in all modern browsers and platforms such as computers, smartphones, PDAs, netbooks, etc.

In reality, everything is more mundane. Browser developers can't afford to make their brainchild work only with the "correct" code. And all due to the fact that most of the sites in the world simply will not be displayed in such a browser. Both developers and users are to blame for this state of affairs. The former did not provide proper support for the specification in their browsers, and the latter did not bother to follow it.

For these reasons, XHTML 1.x is just a semblance of HTML, but with a stricter syntax, and not a promising markup language that is definitely worth switching to because of its unique capabilities.



2024 wisemotors.ru. How does this work. Iron. Mining. Cryptocurrency.