Home > Web Front-end > HTML Tutorial > How to comment html, css, js code? Summary of usage of html, css, and js comments

How to comment html, css, js code? Summary of usage of html, css, and js comments

零下一度
Release: 2017-06-05 10:24:48
Original
3474 people have browsed it

Comment tags are supported in all browsers.

The comment tag is used to insert comments in the source code. Comments will not be displayed in the browser.

You can use comments to explain your code, which will help you edit the code at a later time. Especially useful when you write a lot of code.

It is also a good habit to use comment tags to hide scripts that are not supported by the browser (so that the script will not be displayed as plain text). How to comment the html, css, and js codes specifically? The following is a summary of usage examples of html, css, and js comments!

How to comment html, css, js code? Summary of usage of html, css, and js comments

1. Understand html, css, js comments

1. Html commentsHtml Introduction to the symbols for marking text comments in Html

In this article, let’s learn about the symbols for marking text comments in Html

HTML comments, we often have to make some HTML next to some code Note, there are many benefits to doing this, such as: it is convenient to search, it is convenient to compare, it is convenient for other programmers in the project team to understand your code, and it is also convenient for you to understand and modify your own code in the future, etc.

Start using

2. Conditional comments in HTML

Previous words

IE conditional comment is a non-standard logical statement provided by Microsoft since IE5. Its function is to flexibly import different html elements for different IE versions of browsers. Obviously, the biggest advantage of this method is that it is a compatible solution officially given by Microsoft and can also identify IE

through W3C verification

Because starting from IE10, the IE browser no longer Conditional comments are now supported. Therefore, the following writing method can only recognize IE9-browser

[Note] There must be no space between the two -- and the left bracket [, otherwise it will be invalid

3. Share An example of how Translater.JS cleverly uses HTML comments to translate pages

Follow JSDigs to give you something to do occasionally.

This is a page translation solution that utilizes HTML comments. For a small number of static pages, this solution appears simpler. It has no dependencies and is only compressed (~2kb).

2. Specific usage examples of html, css, and js comments

1. Introduction to some advanced usage of CSS comments

Quasi-qualified selectors

You should avoid over-qualified selectors. For example, if you can write .nav{}, try not to write ul.nav{ }. Excessive modification of selectors will affect performance, affect class reusability, and increase selector privacy. These are things you should try to avoid.

But sometimes you may want to tell other developers the scope of use of a class. Taking .product-page as an example, this class looks like a root container, which may be an html or body element, but it cannot be determined based on .product-page alone.

2. Standard usage of html, css and js comments

Add necessary comments, a good habit that a responsible and ethical front-end must have , which can greatly improve the maintainability and readability of the code. The editor below will introduce to you a summary of the standard usage of html, css and js comments. Friends who need it can refer to it

3. HTML comments - learn HTML+CSS at your fingertips

What are code comments? The function of code comments is to help programmers mark the purpose of the code. If you look at the code you wrote after a while, you can quickly remember the purpose of this code. Code comments not only make it easier for programmers to recall the purpose of previous code, but also help other programmers quickly understand the functions of your program, making it easier for multiple people to collaborate on developing web page code.

3. Related questions and answers

1. What is the shortcut key for adding comments in CSS?

2. javascript - How to use nodeType information to write a function to get all HTML comments in the area

[Related recommendations]

1. html comments

2. C# Example of method to remove comments based on regular expression

3. View java source code and detailed introduction of comment method

The above is the detailed content of How to comment html, css, js code? Summary of usage of html, css, and js comments. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template