如何在网页中显示缩进的源代码? HTML? CSS? [英] How to display source code with indent in a web page? HTML? CSS?

查看:225
本文介绍了如何在网页中显示缩进的源代码? HTML? CSS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在winform上显示一些WebBrowser控件的源代码。我想用HTML标签来装饰源代码,例如颜色,字体和大小。但我发现很难正确显示缩进

I want to show some source code with the WebBrowser control on a winform. And I want to decorate the source code with HTML tags, such as color, font, and size. But I found it difficult to display the indent properly.

准确地说,我的源代码保存在String []中,持有适当的缩进(空格或制表符)。

To be precise, my source code are held in String[], and each String holds the proper indent (space or tab) already. But it seems these kinds of indent are just ignored by the WebBrowser control.

有人可以告诉我怎么办?

Could someone tell me how to?

推荐答案

< pre> 元素(使用 < code> 元素,以标记要语法高亮的部分)

The <pre> element (using <code> elements with appropriate class names to mark up the parts you want to syntax highlight)

<pre><code class="javascript"><code class="keyword">function</code> <code class="name">foo</code>()…

这篇关于如何在网页中显示缩进的源代码? HTML? CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆