How can I style code listings using CSS?

后端 未结 6 1725
生来不讨喜
生来不讨喜 2021-01-29 23:56

I\'d like to display snippets of programming language code, and also HTML code, inside an HTML document using CSS. I want it to be indented and in fixed-width font... I\'m think

6条回答
  •  甜味超标
    2021-01-30 00:41

    You can take a look at the prismjs to highlight the code.

    You can customise the package as your wish from here and the footprint of this package will be still minimal.

    Once you have a package, then you can use it as below:

    
    
      
        ...
        
      
      
        ...
        
      
    
    

    Once the above setup is done, then you can use it like below:

    p { color: red }

提交回复
热议问题