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.
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?
You can indent elements by moving them two spaces to the right. This will make your code more readable by other developers and shows the relationship between the child and parent HTML elements.
For help with indenting text with HTML, see: How to indent or tab text on a web page or in HTML. No. HTML code does not need to be indented, and all browsers and search engines ignore indentation and extra spacing.
I like to paste my code in a Gist and then display it that way. Github will recognize the code and format it accordingly.
If you're going to be doing it often you could try markdown.
Or use a one-off formatter like Syntax Highlighter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With