XHTML, speak?
One of the most sad things whom I notice when nabredaju on Russian-speaking the web - razrabotchickie of community is a full unwillingness to understand essence of questions. When something is impossible to someone, he all over again asks it in a forum where the heap of false "gurus" starts to tell to him nesusvetnuju bosh. Then, if will carry, somebody will give the link to any more - less adequate clause{article} which can concern a question in part. Advice{council} to esteem the primary source (for example the specification of language) it is usually perceived as mockery therefore as in English all ” freely talk “ only in the resumes.
All this results to that Russian web - community is full perfect strange myths, pugajuhhe contradicting to logic:
* ” It is necessary to impose and tables, and div'ami “
* ” 1 em = 16 px “
* ” It is necessary to write on XHTML, instead of on HTML “
Concerning the last - today's clause{article}.
” The spoon no “
First, it is necessary to understand precisely, that only technically any XHTML in a modern web does not exist. For that simple reason, that the most widespread browser which people use, XHTML to display is not able. If IE to feed real XHTML-page he will show her{it} as any other XML-document - as a tree of elements.
Many here will think, that I have overeaten lebedy, and I carry bosh because, for example - the known site at which in surse from above it is unambiguously written, what is it XHTML 1.0, and validator confirms, that so it and is. And IE it{him}, certainly, displays.
Difficulty here that browsers find out type of the document not on DOCTYPE. Instead of it they look that is specified in headings of the HTTP-answer with which there has come the document. And it is written there in overwhelming majority of cases:
Content-type: text/html
… well and more the coding, probably. And it means, that the browser for display of the document uses HTML-nyj parser. That the browser started to display the document by rules XHTML, two things are necessary:
* The type should be xml'nym: application/xml, text/xml or recommended for XHTML - application/xhtml+xml
* Elements should belong registered for XHTML to space of names is that piece xmlns = " http: // www.w3.org/1999/xhtml "
If so to make, as I have already said, IE, at which special XHTML-parsera no, it will be simple to show a tree of elements, and new browsers really will join in a XHTML-mode.
DOCTYPE
It is necessary to specify, what for all taki it is necessary DOCTYPE. As I already wrote in clause{article} about validaciju, theoretically, he specifies the separate document - DTD - on which it is possible fomal`no to check up syntax XHTML. But standard XML allows browsers of it to not do{make} and be nevalidirujuhhimi parserami. They also do not do{make}. And the unique program which taki uses DTD is itself validator (to me it reminds the private requirement to muscovites to carry with itself the passport only that the militia could check his{its} presence:-)).
Nevertheless, browsers all the same use line DOCTYPE. But only for that on concurrence of this line to certain internal patterns to include different modes of return compatibility. For example, whether IE6 will count the sizes boksov under the standard or in a mode sovmetimosti with IE5, depends on whether to specify to him DOCTYPE strict (X) HTML whether or not. And in Gecko-browsers of such modes already three: "mysterious", ” as IE “ i "standard".
By the way, were interested strongly I advise to esteem I skin clause{article} Tima Shaving about what harmful DOCTYPE. Tim Shave, by the way, one of authors XML.
And also it is not necessary
I think, I not oshibaju` am strong, considering, that appeals to write only on XHTML are based exclusively on that, what is it fashionably. I remember, that many people in due time izdevatel`ski (knowing the answer) asked, and what for they insert a slash ("/") in tegi <img/> and <br/> and what for they write in the beginning of document DOCTYPE of different variants XHTML. I on the question did not receive any distinct answer.
Because in practice to use present{true} XHTML a) it is difficult and b) practically there is no need.
I shall remind, that cardinal difference XHTML from HTML will be, that XHTML submits rigid XML'nym to rules well-formed'nosti. That is, if in the document though slightly something is wrong, baruzer is obliged to throw parsit` the document and to inform the user about a mistake.
Such severity is necessary and convenient, if your user - the program. Then, the are more simple and rules of syntax, the easier she are strict.
But such behaviour does not approach on a web. It is not interesting to any user to know, how there the author of page or his{its} author CMS somewhere was mistaken. They come to use, instead of to debug. And in a modern web where documents are made of a heap of different untied slices of the information, sinatksicheskie mistakes, unfortunately, are too often. That means, that your correct XHTML-site will be too much time nejuzabel`nym. It is enough to transfer simply, for example, copy-paste'om URL'ku from a browser in blog and, if in URL'ke is ampersandy (?), you receive broken XHTML, which demands, that these ampersandy have been shielded (*amp;).
Pugalka
If all vyshenapisannoe has not convinced you of uselessness XHTML and you illogically think, that ” all this equally is correct “ I want you to scare a little more. Because these moods are usually supported with opinion, that "obehksemelit`" HTML - zadachka all the same simple. That there, in general: to close all tegi, otkavychit` attributes, to shield ampersandy and to insert slashes in single tegi. Actually all is a little bit more complex{difficult}. The small and incomplete list, in is what is it poured out:
*
Contents of elements <script> and <style> cannot be left in the same kind, as in HTML. Because any badge ">" there and then will break all. If it{him} to shield through ” *gt; “ or to conclude in blocks CDATA then will break HTML'nye browsers which such passions do not know and parsjat the text, assuming, that he is not shielded. Besides in XHTML the browser is not obliged in general parsit` contents of comments, and scripts, as is known, often so are shielded on historical reasons.
In a result to satisfy both XHTML, and HTML, you should or use such design which is taking into account all sintaksisy:
<script>
<! - //-> <! [CDATA [//> <!--
...
//-> <!]]>
</script>
Or to bear{take out} scripts and styles in external files.
*
document.write In scripts in XHTML simply does not work. It is necessary to copy with use of DOM-functions
*
In DOM-functions it is necessary to lower{omit} all names of elements in the bottom register. The same for selectors in styles. In XHTML the register of letters matters.
*
Also convenient things do not work: document.body, document.forms, document.images … It is necessary to draw long calls like document.getElementsByTagName (' body ') [0] and document.getElementById (' change_frm ')
*
If you store{keep} any text inside <input type = "hidden" value = "...">, translations of lines inside attribute "value" in XHTML skhlopnutsja in blanks. That it it was not necessary to shield them: ” both *13; and *10; “.
*
Background color body in XHTML is not distributed automatically to all window
In other words, next time, when you will need to impose page for a web, reject vanity and begin her{it} so:
<! DOCTYPE HTML PUBLIC " - // W3C // DTD HTML 4.01 // EN " " http: // www.w3.org/TR/html4/strict.dtd ">
<title> Page </title>
<p> The text
It is perfect validnyj HTML 4.01 strict. And if for you it is not necessary validacija and DOCTYPE it is possible to reduce up to a minimum that only browsers in a standard mode were included:
<! DOCTYPE html>
<title> Page </title>
<p> The text
The sense nevertheless is
There are rare cases when application XHTML is justified and on a web too.
One of scopes - microformats (about which I already somehow wrote). As they are offered as a thing and chelovekochitaemye, and machine-readable simultaneously severity XML'? is already useful to them.
Other, even more rare piece - the mixed documents. XML allows to unite in the same document elements of different XML-languages (as syntax the general{common}). More often it is used for vstavlenija in XHTML pieces of mathematics on MathML and schedules on SVG. Is known blog - Musings - which it widely uses.
However, probably the most useful effect which XHTML has made, lays at all in technical aspects. This letter "X" has played in due time the important role, having made from simple as though all known and boring HTML new fashionable technology. Not be XHTML'?, probably much less people would become interested in ideas of modern imposition CSS'om, division of contents and registration and would began to read specifications even and only to hang up on page a useless button validacii. Let … the Main thing - cumulative effect:-)

|