The main difference between HTML and XHTML is that in XHTML syntax is XML, which is intended to aid in the development of correct and syntactically correct XML documents. XHTML is an XML dictionary, while HTML - this is only the pre XHTML markup language.
Due to the fact that XHTML is a XML, some of the actions. absolutely correct in that HTML4 based on SGML, must be changed. The different rules to be observed in the transition from HTML to XHTML:
1. Documents must be properly formed.
This means that all the elements required to have a closing tag (eg <p> </ p>), or be written in a special form (as <br />), and should be followed correct nesting elements.
Although they avoid overlapping elements in SGML, some browsers were loyal to this and, in most cases, to display exactly what the author wanted to show the document.
nested elements:
<p> distinguish it <em> word </ em>. </ p>
elements overlap:
<p> distinguish it <em> floor. </ p> </ em>
2. The names of the elements and attributes must be in lower case.
XHTML documents must use lower case for all of the names of the elements and attributes HTML. This is necessary because the XML sensitive, for example, and <ul> <ul> is different tags.
3. Rules for writing attribute values.
All attribute values, even digital should be placed in double ( "") or single quotes ('').
attribute in quotes:
<td colspan="8">
attribute is not in quotes:
<td colspan="8">
If the value of the attribute contains ampersand, it must be an mnemonics ("&"). For example, if the href attribute of the element <a> refers to the CGI script, which takes parameters, it (attribute) must be expressed as follows:
http://my.site.dom/cgi-bin/myscript.pl?class=guest&name=user, not so:
http://my.site.dom/cgi-bin/myscript.pl?class=guest&name=user.
Predefined attribute values (for example, the attribute type element input) priflythrennau and must be written in lower case. However, it does not deal with the values of attributes defined by the authors of the papers (such values for attributes id, name or class), which also priflythrennau, but allowed the use of uppercase letters.
Please note that the lead and led by gaps in the values of attributes removed browsers, as one or more consecutive spaces between words (and line) are converted into solitary dash.
XML is not supported minimizing attributes. Couples attribute / value need to be fully discharged. The names of attributes, such as compact and checked, may not appear in the elements without specific values.
attribute is written entirely:
<dl compact="compact">
attribute minimized:
<dl>
4. For nonempty finite element required tags.
In HTML4 based on SGML, the lack of certain elements allow end-tag with the other elements of the subsequent closing tags. This lack of end-Tag is not allowed in XHTML based on XML. All components, except those declared in the document type definition as EMPTY should have the final tag.
closed items:
<p> Here is the text. </ p> <p> Another paragraph with the text. </ p>
outstanding elements:
<p> Here is the text. <p> An additional paragraph with the text.
5. Empty elements
Empty elements required to have the final tag, or the tag is required to end starter />. For example, or <br /> <br /> </ br>.
For compatibility with obsolete browsers should write a space before /> in solitary empty element.
It will be used to tag syntax minimizing empty elements, such as <br /> as an alternate syntax <br /> </ br> allowed XML gives unexpected results in many existing browsers.
When you create an empty object elements whose content model is not EMPTY (eg blank header, or paragraph), should not be used minimizing form (that is needed to use <p> </ p> not <p>).
empty tags closed:
<br /> <hr />
empty tag is not closed:
<br /> <hr />
6. Elements <script> and <style>.
In XHTML elements and <script> <style> advertised as being content # PCDATA. As a result, "and & Home will be seen as a markup, such as <and> <style> or in the section labeled CDATA, avoiding decrypt these Mnemonic.
<script type="text/javascript"> //<![ CDATA [
... unescaped script content ...
//]]></ script>
CDATA Sections properly processor and XML are nodes in the document object model (Document Object Model)
The alternative may be the use of external documents scripts and styles.
7. Exceptions SGML.
SGML provided creators document type definitions to exempt certain elements of the contents of the element. Such prohibitions (called "exceptions") are impossible to XML.
For example, strict HTML4 Document Type Definition (Strict DTD) prohibits the attachment element <a> <a> other element in any depth. Although the ban and may not be available in a document type definition, certain elements can not be invested.
In XHTML:
<a> can not contain other elements <a>.
<pre> could not contain elements <img>, <object>, <big>, <small>, or <sub> <sup>.
<button> could not contain elements <input>, <select>, <textarea>, <label>, <button>, <form>, <fieldset>, or <iframe> <isindex>.
<label> can not contain other elements <label>.
<form> can not contain other elements <form>.
8. Items with the attributes of "id" and "name"
HTML 4 defined attribute a name for the elements, applet, form, frame, iframe, and img map, and also introduced id attribute. Both attribute set up for use as identifiers fragment.
In XML fragment identifiers are of the type ID, and the element can be only one attribute of type ID. Thus, in XHTML 1.0 id attribute is defined as an attribute of type ID. To be sure that XHTML 1.0 documents are properly structured XML documents, papers must use XHTML 1.0 id attribute to determine the fragment identifiers, and even those elements that historically had been the attribute name.
It should also be remembered that id attribute value in the document must be unique.
In XHTML 1.1 for the elements of a map, and the attribute name removed, it should be used instead of id attribute.
9. Double dash in the comments
Commenting double dash "-" may mark only the beginning and end of the comment.
<! - use separator written below - not a comment - invalid ->
<!--------------------------------->
<! - use separator written below - - can be a comment - - faithful ->
<!--==== - - - - ====-->
Thus, double dash "-" does not denote the beginning and end of the commentary in the text should be replaced by anything or MAC address, for example "- -".
10. Characters and the text & document
Characters and & in the text should be replaced by the corresponding sequences and &.
It is not necessary, but also desirable to replace and> at>.
11. Here is a sample of the minimum XHTML document:
<? xml version = "1.0" encoding = "windows-1251?">
<! DOCTYPE html PUBLIC "- / / W3C / / DTD XHTML 1.1 / / EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="ru">
<head>
<title> XHTML </ title>
</ head>
<body>
<p> Details on the website W3C Markings: <a href="http://w3c.org/MarkUp/"> http://w3c.org/MarkUp/ </ a>. </ p>
</ body>
</ html>
The root element of the document should (must) be <html>.
The root element document is required to identify the namespace by using XHTML xmlns attribute [XMLNAMES]. Namespace XHTML http://www.w3.org/1999/xhtml identified.
It is obliged to attend the announcement DOCTYPE pre root element (<html>).
Public identifier included in the announcement DOCTYPE, must be a reference to a document type definitions.