Validator - what is it? Why is a micro-marking validator necessary?

Let's talk about code verification tools. A special tool that is created for this purpose is called a format validator. HTML will be used as an example. The validator for this markup language is quite suitable in order to explain the principle and give an example.

Why is it needed?

validator what is it
It happens that you write the program code, everything seems to work correctly, but it wonโ€™t hurt to check. So, let's say we created an HTML page. When we recall the validator, this means that we are interested in how competently it is made in terms of the accepted standard (the better, the more correctly and on more computers it will work).

Customize the conditions

The severity with which the page will be checked is recorded in the <! DOCTYPE> tag. If you do not specify it, then it will be examined in the most thorough manner, and in the report the validator will indicate all errors and departures from the standards. Also keep in mind that validation will follow HTML5 guidelines. To specify a different version or mitigate the search for deviations, use this tag. By the way, in addition to the version for HTML, there is also a CSS validator. It will allow you to check the construction of the cascading style sheet and its compliance with the latest standard. This chance, if you are already interested in this topic, it is better not to neglect it.

DOCTYPE tag verification directions

At the moment, there are these types of checks:

  1. Strict according to the latest standard.
  2. Transitional.
  3. Strict.
  4. With frames.

By the way, it is advisable to always specify DOCTYPE. After all, if this is not done, different browsers with different settings will display the page in different ways. And the desired file will be very ugly displayed. It should be noted that this affects only the visual component, while the performance is not affected.

Letโ€™s say a word about mistakes

code validator
Even when checking a small document, the code validator can find many programmer misses. Is it mandatory to eliminate them all? Not. Most technical errors are not critical, the maximum that they can do is to slow down the site a little. Although, if this option is valuable to you, ignoring them will fail. It should also be noted that some errors may appear even at the time of compilation by the PHP interpreter.

Other items

The fact that the HTML validator checks the code is certainly good. Are there any features regarding RSS feeds and cascading CSS tables? Yes, there are validators for them too. Remember: they only check that the code complies with the standards. And what is written there - they do not care. Therefore, if you are primarily interested in the quality of the page and site, you must check them.

Online check

validator css
In order not to spray their efforts on various programs, many developers have chosen an Internet validator. What is it and how does it help? Such services are usually already configured to check all three components (RSS-feeds, CSS and HTML). Their versatility is commendable. But the correctness of the HTML is better to check separately again. If we talk about the benefits of online services, it should be noted that there is no need to copy all the code. It is enough to enter the site address, and in a moment errors will be displayed. There are also extensions for browsers that can also partially or fully check whether an open page meets accepted standards.

What is included in the validation?

micro-marking validator
This process is divided into several parts:

  1. A search is made for syntax errors.
  2. Checks the nesting of tags. They always close in the reverse order of how they came off. And if something is wrong - you will be notified.
  3. Check for compliance with the specified Document Type Definition. Automation scans and determines whether everything is correctly (tags, attributes) written, relative to the version of the markup language that is declared.
  4. Check for foreign elements. A search is made for what is in fact in the code, but not in the Document Type Definition.

You must understand that this is all - logical checks. In this case, it is not important how the validator is implemented. What does this mean in practice? If at least one check fails, the code will not be considered valid. In the end, each serious program will give recommendations on what needs to be fixed (and may even tell you how to do it).

Arguments for

The main reason why a micro-markup validator is needed is to ensure cross-browser compatibility for the site or its individual page. The fact is that every program that helps you browse the Internet has its own parser. Therefore, the only way to be sure that the code will function correctly in all browsers is to run it through the validator. What else does it give?

The fact is that each browser has its own mechanism for correlating errors in program code. Therefore, perhaps he will be able to correct the situation with an invalid program, or he may aggravate everything. These were arguments for, but there are also against.

So, it is worth noting that the micro-marking validator is very strict. And browsers can fix some errors on their own. Therefore, if the first task is to work properly, the appearance can be partially ignored.

Reviews using validator

html validator
What does this give in practice? Compared to what is used in real applications, the validator has extraordinary requirements. Of course, he may show some errors that interfere with normal operation, but he should not try to please him completely. Also often indicate that it is not always trouble-free to check for extraneous elements. But these include user attributes, which are not recognized by standards, but are used by developers to facilitate production processes.

If you have doubts about the aesthetics of the appearance of the page, then they are in vain. So, if you specify Doctype, the browser parser will be switched to a certain mode. But this will not lead to the fact that it will be downloaded, and the code will be checked for compliance with it. Therefore, browser parsers are already preconfigured to ensure that there will be a certain lack of code validity. So with custom attributes: they are successfully recognized and processed. An example is ARIA technology. It works with attributes that complement the semantic meaning of the code, so the validator swears. What is it: good or bad? On the one hand, the code works and provides accessibility features. And on the other - a deviation from the standards. But in the case of ARIA, this is entirely justified.

Conclusion

validator is
In the end, I want to say that everyone independently chooses whether to use a validator for him or not. The article described the features and nuances of this step, and the decision is up to the reader.

Source: https://habr.com/ru/post/K2274/


All Articles