How to make comments in html

Before you learn how to make comments in html, you need to understand what they are for. If you are interested in such information, then you probably already know what html is, so we will not dwell on this issue. Some web developers do not pay enough attention to the arrangement of comments in their codes. In single-page sites, such an error may go unnoticed. But when it comes to huge portals, small comments will save time and simplify your life. Plus, notes allow other developers to understand your code when additional explanation is required.

html comments

goal

Creating an html page sometimes can not do without confusing codes and ever-repeating tags. New classes, selectors, id-identifiers, etc. All this can literally drive you crazy. The html comments are designed to ease the plight of web developers. Indeed, when the site code stretches far down, it is difficult to remember what and where is located. It is comments that help to make small notes directly in the html-code, which will not be visible to your users. Beginners rarely use this tag. But already experienced specialists highlight the huge, useful property of comments. This tag is especially effective when several developers work on the code at once. Instead of asking questions each time and tearing your partner from work, you just need to look at the comments.

html comments

Creature

In order for a new line with a comment to appear in your code, you must add the following entry: <! - ->. This is what this tag looks like in html. Everything inside it will not be displayed to users. Html comments should not be stretched over several lines and contain any code (this is considered bad form). They should contain only a certain description of the developer’s intentions regarding the insertion of this particular tag, attribute or value. Although among the high level of masters there is an opinion that the code should be written in such a way that no additional explanations are required. But, unfortunately, not everyone has the gift of writing html pages.

html page creation

Features

The <! - -> tag has some of its own characteristics. For example, you can add any other tags inside it, but you cannot create nested comments. This will lead to not quite expected result. Html comments are widely used to test web pages. For example, when you need to look at a site without a specific tag, but you cannot delete it, since it will be difficult to restore all the source code. In this case, you just need to put the necessary part of the page in the comments. And then the tag will be ignored by the browser. But it is worth noting that all comments can be traced if you open the source code of the page. And this can be done by each user. Therefore, do not put any important information inside this tag.

Conclusion

Comments in html can help you and other webmasters figure out your codes. But try to build your sites in such a way that an explanation of your pages is not required.


All Articles