Home
Home Page
Than differ id and class
Creation WAP of a page
Passions around AJAX are heated
Answers to often asked questions on XHTML and HTML
The sanction of the screen and marking of pages
Two styles ajax'?
Business Macromedia lives
XHTML+CSS. Advantages are obvious
Microformats
The semantic network based on microformats
Fonts and CSS
CSS from And up to I
Properties of the text
Illumination of the link
Change of a background in the table
Fixation of fonts on page with the help of the table of styles
Krossbrauzernoe alignment on the center
Polling with help AJAX
HTML
Links
 

HTML "XHTML" XML

The basic distinction between HTML and XHTML will be, that in XHTML syntax XML which is intended for the help in development sintaksicheski correct and correct documents XML. XHTML dictionary XML while HTML is only previous XHTML a markup language is applied represents.


In connection with that, that XHTML is application XML, some actions. Which are completely correct in HTML4 on base SGML, should be changed. We list rules which are necessary for observing at transition from HTML to XHTML:



1. Documents should be correctly generated.


It means, that all elements are obliged to have closing teg (for example), or to be written in the special form (for example,

), and also the correct enclosure of elements should be observed.


Though perekryvanie elements it was not supposed and in SGML, some browsers loyally concerned to this and in most cases displayed that the author of the document wanted to show.


CORRECTLY: the enclosed elements


We select this word.


INCORRECTLY: elements are blocked


We select this word.

2. Names of elements and attributes should be in the bottom register.


Documents XHTML should use the bottom register for all names of elements and attributes HTML. It is necessary, as XML is sensitive to the register, for example, <ul>

And <UL>

These are various tegi.

3. Rules of a spelling of values of attributes.


All values of attributes, even digital should be made in double (" ") or unary (") inverted commas.


CORRECTLY: attribute so-called



<td colspan = "8">


INCORRECTLY: attribute not so-called



<td colspan=8>


If value of attribute contains ampersand, he should be expressed by mnemonic (" *amp; "). For example, if the attribute href an element <a> refers to script CGI which accepts parameters, he (attribute) should be expressed so:


http: // my.site.dom/cgi-bin/myscript.pl? class=guest*amp; name=user, instead of so:

http: // my.site.dom/cgi-bin/myscript.pl? class=guest*name=user.


The predetermined values of attributes (for example attribute type an element input) registrozavisimy also should be written in the bottom register. However, it does not concern values of attributes of documents determined by authors (for example value for attributes id, name or class) which also registrozavisimy, but suppose use of symbols in the top register.


It is necessary to take into account, that conducting{leading} and conducted blanks in values of attributes leave browsers, and one or several consecutive blanks between words (and also translations of lines) will be transformed in single mezhslovnyj a blank (a symbol of blank ASCII in the western languages).


XML does not support minimization of attributes. Pairs attribute / value necessarily should be written out completely. Names of attributes, such as compact and checked, cannot appear in elements without the certain values.


CORRECTLY: the attribute is written completely



<dl compact = "compact">


INCORRECTLY: the attribute is minimized



<dl compact>



4. For nonempty elements are necessary final tegi.


In HTML4 on base SGML, some elements supposed absence final tega at presence of other subsequent elements with closing tegami. Such absence final tegov is not supposed in XHTML on base XML. All elements, except for what are declared in definition such as the document as EMPTY, should have final teg.


CORRECTLY: the closed elements



<p> Here any text. </p> <p> Still the paragraph with the text. </p>


INCORRECTLY: open elements



<p> Here any text. <p> Still the paragraph with the text.



5. Empty elements


Empty elements are obliged to have final teg, or starting is teg obliged to come to an end/>. For example, <br/> or <br> </br>.


For compatibility with out-of-date browsers it is necessary to write a blank before/> in a single empty element.


It is necessary to use the minimized syntax for tegov empty elements, for example, <br/> as alternative syntax <br> </br>, admitted XML, yields unpredictable results in many existing browsers.


At creation of empty object of an element, whose model of contents not EMPTY (for example, empty heading or the paragraph), it is not necessary to use the minimized form (i.e. it is necessary to use <p> </p>, instead of <p/>).


CORRECTLY: empty tegi are closed



<br/> <hr/>


INCORRECTLY: empty tegi are not closed



<br> <hr>



6. Elements and.


In XHTML elements <script> and <style> are declared as having contents *PCDATA. As result of it, <and also will be considered{examined} as the beginning of a marking, and mnemonic, such as *lt; and *amp;, will be considered as processor XML mnemonikami symbols <and and accordingly. Carry of contents of elements <script> or <style> in the section marked CDATA, will allow to avoid decoding of these mnemonik.



<script type = "text/javascript"> // <! [CDATA [

... unescaped script content...

//]]> </script>


Sections CDATA are distinguished by processor XML and are sites in objective model of the document (Document Object Model)


Alternative can be use of external documents of scripts and styles.



7. Exceptions SGML.


SGML gave founders of definitions such as the document an opportunity to exclude some elements as contents of an element. Such prohibitions (named "exceptions") are impossible in XML.


For example, Strict definition such as document HTML4 (Strict DTD) forbids an investment of an element <a> in other element <a> on any depth. Though these prohibitions also can be absent in definition such as the document, the certain elements cannot be put.


IN XHTML:

<a> Cannot contain other elements <a>.

<pre> cannot contain elements <img>, <object>, <big>, <small>, <sub> or <sup>.

<button> cannot contain elements <input>, <select>, <textarea>, <label>, <button>, <form>, <fieldset>, <iframe> or <isindex>.

<label> cannot contain other elements <label>.

<form> cannot contain other elements <form>.



8. Elements with attributes "id" and "name"


HTML 4 has defined{determined} attribute name for elements a, applet, form, frame, iframe, img and map, and also has entered attribute id. Both these of attribute are created for use as identifiers of a fragment.


In XML identifiers of a fragment have type ID, and in an element there can be only one attribute such as ID. Thus, in XHTML 1.0 attribute id is determined as attribute such as ID. To be confident, that documents XHTML 1.0 are correctly structured documents XML, documents XHTML 1.0 are obliged to use attribute id for definition of identifiers of a fragment, and even in those elements which historically had attribute name.


Also it is necessary to remember, that value of attribute id within the limits of the document should be unique.


In XHTML 1.1 for elements a and map the attribute name is removed, instead of him{it} it is necessary to use attribute id.



9. Double dashes in comments


In comments double dashes "-" can designate only the beginning and the end of the comment.


INCORRECTLY:



<! - to use a separator written below - it is impossible also this comment - it is incorrect->

<!--------------------------------->


CORRECTLY:



<! - to use a separator written below - - it is possible also this comment - - it is correct->

<! - ==== - - - - ====->


Thus, double dashes "-" not designating started also the end of the comment in his{its} text should something be replaced or divided{shared} by a blank, for example " - - ".



10. Symbols <and and in the text of the document


Symbols <and and in the text of the document should be replaced with corresponding sequences *lt; and *amp;.


There is no necessity, but it is desirable to replace as well> on *gt;.



11. A sample of minimal document XHTML:



<? 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 " xml:lang = "ru">

<head>

<title> XHTML </title>

</head>

<body>

<p> Details about a marking on site W3C: <a href = " http: // w3c.org/MarkUp / "> http://w3c.org/MarkUp/ </a.> </p>

</body>

</html>


Root element of the document should (is obliged) to be <html>.


The root element of the document is obliged to designate space of names XHTML by use of attribute xmlns [XMLNAMES]. The space of names XHTML is determined in <http: // www.w3.org/1999/xhtml>.