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

What are the two ways to write css comments?

王林
王林Original
2021-03-04 16:22:3512186browse

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 */

Example:

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

(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 c9ccee2e6ea535a969eb3f532ad9fe89 tag, in some older browsers you can also use 19791207a4e0a22c816ac020ecd8cae0 to comment the CSS code, although this is not possible. recommended. Like most other programming languages ​​that use the /* */ syntax for comments, comments cannot be nested. In other words, the first */ mark after /* will end the comment.

Related recommendations: CSS tutorial

The above is the detailed content of What are the two ways to write css comments?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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