What are HTML comments?

HTML markup language allows you to create a beautiful and structurally high-quality website. But when creating significant resources, it is difficult to remember which part of the code is responsible for what. And if you take up a project after six months or a few years, then remember what it is, it is quite difficult, and performance will suffer. To facilitate this aspect of the life of programmers, it is also possible to comment on the lines of program code written by them.

What are HTML comments?

comments in html

What is a comment in programming in general? This is certain information that is added to the code for a better understanding by the programmer. The text message does not affect the execution of commands or does not appear on the pages (as happens when making comments in HTML).

Additionally, it should be said that in the comments can be placed various elements like text links to pictures, a part of the code (while working on the page) or just plain human-friendly text.

The difference with respect to most other programming languages ​​can be called the fact that nested comments (when one is located in another) are not provided here. Comments in HTML inside some element, like the same link to the page, are also invalid.

Implementation example

How, in general, looks like an example of the implementation of such a comment? Initially, you should open a tag that means information for a person, add everything you need and close it. A simplified diagram looks like this:

<!-- текст -->

The comment is inserted into a separate line. Here is what a real HTML comment in the code might contain:


<!—Сейчас я буду подключать каскадную таблицу стилей для расположения деталей страницы -->


Notes and Specs

html comment in code

When developing, one should take into account that a double hyphen, which can be seen in the example, is perceived as part of a comment, therefore its presence is accompanied by an error during validation of the document.

Support for the ability to leave information is present in all modern standards, so now comments in HTML are a common thing. Also, comments are processed by all popular browsers for both desktop computers and mobile devices.Due to the ease of service, the same methods are used in all versions, which allows to conclude that in the future mobile and regular versions of sites will no longer differ.

Related news

What are HTML comments? image, picture, imagery

What are HTML comments? 69

What are HTML comments? 32

What are HTML comments? 14

What are HTML comments? 11

What are HTML comments? 90

What are HTML comments? 11

What are HTML comments? 88

What are HTML comments? 9