XHTML
XHTML (eXtensible HyperText Markup Language) is basically HTML expressed as valid XML. It is stricter on a technical level, but this allows it to be easier later when making changes or looking for errors among others. In its version 1.0, XHTML is just the XML version of HTML, so it basically has the same functionality, but it complies with the stricter XML specifications. Its objective is to advance the World Wide Web Consortium's project to achieve a semantic web, where the information and the way of presenting it are clearly separated. Version 1.1 is similar, but splits the specification into modules. In successive versions, the W3C plans to break with the classic tags brought from HTML.
Advantages over HTML
The main advantages of XHTML over HTML are:
- Elements of different XML namespaces can be incorporated (such as MathML and Scalable Vector Graphics).
- A browser does not need to implement heuristics to detect what the author wanted to put, so the parser can be much easier.
- As XML is easy to use tools created for processing generic XML documents (editors, XSLT, etc.).
Appendix
The XHTML standard indicates in an informative appendix a way to write XHTML in such a way that current browsers that only understand HTML will process it as if it were HTML. For this, a document must be created with some restrictions and considerations, and serve it with the "content-type" text/html, instead of the correct one for XHTML.
Some of the proposed rules for making XHTML "look like" HTML are:
- Do not use process instructions.
- Vacuum elements (such as ≤b) should be written ≤b /, i.e. in abbreviated form and with a space before «/».
- The abbreviated form should not be used for non-vacuum elements that have no content, i.e.: it should not be written.
- The elements must be correctly nested.
- The elements must contain the title attribute in mandatory form.
For some authors, the inclusion of this appendix in the standard was a mistake and they consider it a mistake to use XHTML in this way.
Differences between HTML and XHTML
The following list shows some rules of XHTML 1.0 that differentiate it from HTML 4.01. Many of these differences come with the change from being an SGML application to being an application of the stricter XML:
- Empty elements should always be closed:
- Wrong:
- Right:
o
o
Note: Any of the three forms is valid in XHTML. For compatibility according to the "Appendix C" must be used
.
- Wrong:
- Non-empty elements should also be closed always:
- Wrong:
Primer párrafo
Segundo párrafo
- Right:
Primer párrafo
Segundo párrafo
- Wrong:
- The nesting elements must have a correct opening/closure order (the one that opens last, must be closed first).
- Wrong:
Texto
- Right:
Texto
- Wrong:
- The attribute values must always be locked between quotation marks (simples or doubles).
- Wrong:
- Right:
- The names of elements and attributes should be in lowercases.
- Minimization of attributes is not permitted (the name of the attribute is used as a value).
- Wrong:
- Right:
- Disapproved attributes in HTML 4.01 are not part of XHTML.
- Wrong:
Blue text
- Right:
Blue text
Rules for strict DTDs
- The text should not be inserted directly into the body (within the label body).
- Wrong:
Texto plano
- Right:
Texto plano
- Wrong:
- Block elements should not be inserted into line elements.
- Wrong:
Título
- Right:
Título
- Wrong:
Contenido relacionado
Template:In development
Coding
MetaWiki
Más resultados... - Right:
- Wrong: