简体   繁体   中英

Css rule for comments inside html code tag?

How to set a css rule so I can format comments inside html code tags?
something like regex //.*

<pre>
  <code>
    git reset [file]        //unstage but preserve file content
    ...
  </code>
</pre>

You can put the comments in tags:

<pre>
  <code>
    git reset [file] <span class="comment">//unstage but preserve file content</span>
    ...
  </code>
</pre>

Then in CSS:

.comment {
  color:grey;
  /*Your CSS here*/
}

If you dont want to use tags then you will need to use JavaScript to loop through all the code tags, locate comments, and apply the class.

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