Summary of standard usage of html, css and js comments

Summary of standard usage of html, css and js comments

Adding necessary comments is a good habit that a responsible and moral front-end developer must have, which can greatly improve the maintainability and readability of the code. First of all, you need to be familiar with the writing of comments in html, css, and js:

HTML comments:

<!--Comment content-->

CSS comments:

//Comment content single line comment (not recommended, because some browsers may not be compatible and have no effect)
/*Comment content*/ Multi-line comment (recommended)

JavaScript:

//Comment content single line comment
/*Comment content*/ Multi-line comment

Summarize:

//Comment content (insert single-line comments in CSS or JavaScript)
/*Comment content*/ (Insert multiple lines of comments in CSS or JavaScript)

Next, we will summarize where comments are used in these types of code and how to write comments. (It may vary according to personal habits)

1. HTML comments

Where used:

1) It is usually used after the end of some main node labels, such as:

<div class="wrap">
<div class="main">
...
</div><!--main end-->
<div><!--wrap end-->

2) Used after the end of some loops, such as:

<ul class="list">
    <li>111111</li>
    <li>222222</li>
    <li>333333</li>
</ul><!--list loop-->

All of this is to make the program more convenient and clear when nesting. Making things convenient for others also makes things convenient for yourself. The programs are nested very messily, and it will be a very complicated process for you to modify them.

2. CSS comments

It is usually used above the definition of a module style to indicate which module this style applies to, such as:

/*General - Comments*/
.comment{...}
/*Photo Album*/
.photo{...}
/*share*/
.share{...}
/*vote*/
.vote{...}

3. JavaScript comments

Comments are usually added above a function to describe the function, author, author information, and modification time.

//========================================================
//Truncate characters//steepvi
//rtx:*******
// 2010-10-14
//========================================================

Finally, comments are also characters that will generate traffic. Therefore, when the page is published to the official address, it is best to add an optimization process.

The compression process is a non-reversible process, which ensures that the local file is the latest and annotated file, and is uploaded to the server after compression. Server-side files cannot be used for local debugging.

The above is a summary of the standard usage of HTML, CSS and JS comments introduced by the editor. I hope it will be helpful to everyone. If you have any questions, please leave me a message and the editor will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!

<<:  Bootstrap 3.0 study notes page layout

>>:  Concat() of combined fields in MySQL

Recommend

Summarize the User-Agent of popular browsers

1. Basic knowledge: Http Header User-Agent User A...

Native JS to achieve digital table special effects

This article shares a digital clock effect implem...

Implementation of master-slave replication in docker compose deployment

Table of contents Configuration parsing Service C...

Understanding MySQL Locking Based on Update SQL Statements

Preface MySQL database lock is an important means...

vue+el-upload realizes dynamic upload of multiple files

vue+el-upload multiple files dynamic upload, for ...

Learning to build React scaffolding

1. Complexity of front-end engineering If we are ...

Elementui exports data to xlsx and excel tables

Recently, I learned about the Vue project and cam...

Let's learn about the MySQL storage engine

Table of contents Preface 1. MySQL main storage e...

mysql obtains statistical data within a specified time period

mysql obtains statistical data within a specified...

How to query the minimum available id value in the Mysql table

Today, when I was looking at the laboratory proje...

Simple example of adding and removing HTML nodes

Simple example of adding and removing HTML nodes ...

Solution to the lack of my.ini file in MySQL 5.7

What is my.ini? my.ini is the configuration file ...

JavaScript deshaking and throttling examples

Table of contents Stabilization Throttling: Anti-...