简体   繁体   中英

CSS Nested Comment Multiline Code Comment Inside Other Comment

Inside a CSS file I've got 2 ways to format a body element. How can I comment to select body style 1?

/* body style 1 */
body {
  background-color: #E6F6F6; /* color 1 */
}

/* I want to comment all from here to end */
/*
/* body style 2 */
body {
  background-color: #F6F6F6; /* color 2 */
} /* this right bracket is not commented out */
p {
    font-size: 10px;
}
*/

CSS comments run until the first instance of */. You cannot nest CSS comments.

You could do something like this, but it's messy:

/* body style 1 */
body {
  background-color: #E6F6F6; /* color 1 */
}

/* I want to comment all from here to end */
/*
/* body style 2 */
/*body {
  background-color: #F6F6F6; /* color 2 */
/* } /* this right bracket is not commented out */
p {
    font-size: 10px;
}
*/

remove the /*color 2*/ comment and additional comments and then it will work

/* body style 1 */
body {
  background-color: #E6F6F6; 
}

/* I want to comment all from here to end */

/* body style 2 */
/*
body {
  background-color: #F6F6F6; 
} 
p {
    font-size: 10px;
}
*/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM