Home > Web Front-end > CSS Tutorial > What are the two ways to write css comments?

What are the two ways to write css comments?

王林
Release: 2023-01-03 09:27:44
Original
12242 people have browsed it

The two ways to write css comments are single-line comments and multi-line comments. The syntax format is [/* Comment */]. There is no other way to declare annotations in an external, standalone CSS file. The first [*/] mark after [/*] will end the comment.

What are the two ways to write css comments?

The operating environment of this article: windows10 system, css 3, thinkpad t480 computer.

CSS comments are used to add extra explanation to the code, or to prevent the browser from parsing CSS code within a specific area. Comments have no effect on document layout.

The syntax is as follows:

Comments can be written anywhere in the style sheet that allows spaces. Comments can be written on one line or on multiple lines.

/* Comment */
Copy after login

Example:

/* 这是一行单行注释 */
/*
分为
几行
的
注释
*/
/* 下面的注释用于禁用特定的样式 */
/*
span {
  color: blue;
  font-size: 1.5em;
}
*/
Copy after login

(Learning video sharing: css video tutorial)

Description:

/* */ Style The comment syntax can be used as a single-line comment or as a multi-line comment. There is no other way to declare annotations in an external, standalone CSS file.

However, if the CSS code is written in the