ComputersProgramming

Doctype HTML - what is it? What you need to know about the element

Whatever skeptics say, progress is still a phenomenon that can not be stopped. However, while some are indignant over the prolonged move to lunar dachas, others are literally plunged into panic, for to keep up with the changes becomes more and more difficult. An example of such "catching up" are representatives of professions associated with high technology.

While most web designers, programmers and layout designers are much more in line with the spirit of the times than any "Nura Baba", who receives information with a week's delay, and even with significant distortions, the real situation is somewhat different. It is rather difficult to match the level of progress in the sphere of new technologies. Let's consider a simple example: some 5-10 years ago the developer of online games on Adobe Flash could achieve tangible success, numerous "Merry Farmers" are a confirmation. However, even today, this technology is gradually dying out, giving way to a more modern but less studied basic majority of HTML5. By the way, it is HTML5 and is one of the "characters" of our today's story, devoted to the everyday work of HTML-coder.

Doctype HTML - what is it?

This is a high-tech monument to the victims of technology progress. Dashing 90-s, which distinguished themselves not only by the "combat" situation in our country, but also quite a real war of browsers, brought to the world several products that allowed computer users to plow the expanses of the worldwide network. But there is only one catch - popular then Netscape Navigator and Internet Explorer looked at the same pages in completely different ways, respectively, and the creators of the sites created completely different pages for these programs.

Standards? In those years, it was pointless to talk about them - the W3C was in its infancy, and Microsoft, which promoted its IE, was famous for preferring to invent its own bikes that were incompatible with anything. Nevertheless, by the end of that terrible (for the web developers) decade, the situation was still normal: there appeared some semblance of standards, which, albeit not completely, but still respected by all popular browsers.

However, the situation turned out to be such that the standards of the consortium and browser manufacturers turned out to be not all the same. You could very well create an absolutely correct page from the point of view of HTML, CSS and DOM, but your preferred browser persistently did not show what you expected to see.

Nevertheless, the time passed, the developers finally decided to think not only about the competition, but also about webmasters, and he appeared - Doctype HTML. This is a special tagname telling the browser how to view a particular page.

Why do I need Doctype in HTML?

Before the emergence of adequate standards, which began to follow everywhere, many browser developers tried to pull the blanket over themselves, creating their own methods of approach to a particular technology. As a result, the same page looked different in different browsers. However, we have already talked about this, just did not mention that when the producers of programs for web surfing came to their senses, another, no less interesting problem arose.

Imagine the situation: you are a typical web developer of the late 90s. It so happened that most of the time you spend in the browser Internet Explorer 4. Suddenly, Microsoft decides to come to your senses and makes its new browser more "correct", as a result of which it becomes not clear how to write websites and what to do with those already Created. Naturally, if you have enough time, you could rewrite your HTML code in such a way that it conforms to the new standards, but people are lazy creatures.

It is at this point that the Doctype HTML is the most relevant "invention". Depending on what type of document is indicated at the beginning of the page, the browser will choose the most suitable for this case the mechanism of rendering. If there is no Doctype in the HTML-code, the browser will go into compatibility mode (as a rule, but not necessarily). As a result, the same Internet Explorer 6 (even if it's an archive, it will be down), in the absence of the Doctype tag, behaves as if you were working in its fourth version.

Types of Doctype

The Doctype tag has several varieties that can be divided into specific categories. First, it describes the main types of markup language: HTML 4.01, HTML 5, XHTML 1.0 or XHTML 1.1. Secondly, each of these languages has its own sub-sections, pointing to the "coefficient of fault-finding," that is, how rigidly the HTML code is set by the W3C standards. True, in the second case there are two exceptions - HTML5 and XHTML 1.1 do not have any subspecies and have only one form of Doctype HTML. But more on that later…

Strict approach: Doctype Strict

If you prefer to create HTML code that matches each letter of the validator's law, then an additional incentive (other than your own interest) can be the use of Doctype Strict. If you plan to use more advanced XHTML 1.0, then the line with which each element will start should look like this:


Choosing a strict Doctype HTML Public template ensures that any deviation from the standard will be noticed by the browser, after which the incorrectly used tag will be ignored. In particular, in strict mode, any tag, whether it is a form, an image, or another element, must be located inside the block tags. If you decide to do without it, then the browser simply does not display this element, and a list of layout errors will be filled with a couple of entries.

In addition, a number of tags that allow you to format the text, it is also desirable to exclude - strict mode implies the use of CSS.

Human approach: Doctype Transitional

If the severe strict template method does not suit you, or if you are simply accustomed to going against the rules, there is always the possibility of resorting to a more humane type of Doctype HTML Public. W3C took care of those who do not want to give up their habits and want to work in milder conditions, creating a Transitional template that represents a transitional model of approach to validation. This template gives you the opportunity to freely allow yourself some liberties, such as tags that are prohibited by Strict-template, as well as many other approaches to layout that have not lost relevance since the late 90s.

"Soft" Doctype HTML 4 is declared as follows:

For XHTML, the line again looks a little different, but the overall trend remains:

To date, despite the fact that each layout is trying to match the Strict template, it is the transitional Doctype that is most popular. Nevertheless, this template has one conditional limitation: the validator will "reject" any pages in which there are frames. If you need to resort to this method of layout, you should pay attention to the following - the last template.

From General to Specific: Doctype Frameset

The approach for checking the page for matching the Frameset template is generally similar to that of Transitional, however, in addition to the "liberties" listed above, this template gives you the ability to use frames. Frameset has no other differences, so it only remains to list the lines for ads, for HTML 4.01 and for XHTML 1.0:

On the edge of progress

Naturally, having mentioned at the beginning of this article all the HTML5 standard that is gaining popularity, we could not ignore this markup language. It's funny that W3C considers this version of HTML the main one, so its Doctype HTML 5 looks rather modest. In other words, this type definition means that the browser needs to work with "clean" HTML, which HTML5 is considered today, while the fourth version, which is customary for many, is considered to be potentially obsolete.

Other varieties of Doctype

To date, there are several more varieties of Doctype templates, most of which concern XHTML. While the second version of this markup language never came to light, becoming part of the above-mentioned HTML5, the variations of its first version, despite not the highest prevalence, are alive and well.

Is Doctype important?

Perhaps some novice "writers" on HTML will try to ignore the page type declaration. Well, if they did not bring out important information from the above, let's give one simple example. Here is an example of a page using the Transitional template:

Everything looks the way it should look like for a designer, but we need to "mix" Doctype, and we get the following:

As you can see, the page has undergone significant changes: the background image has disappeared, the menu has turned into a mutilated list, some CSS classes are simply ignored, in addition, the page has a second scrollbar.

We hope that this example is sufficiently accessible to explain the importance of what's been written out, so we just have to remain attentive or, ideally, learn to write code that passes strict-validation. I wish you success!

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.birmiss.com. Theme powered by WordPress.