0

Possible Duplicate:
How to display formatted code in webpage

I'm sure this question must have been asked before however I cannot find it anywhere. (I must be searching for the wrong thing)

Much like this site allows you to do, I would like to place c# onto my webpage so that I can write tutorials / examples.

var tute = new Tutorial();    
//Display all of this 
SomeMethod(tute);

is this performed by CSS trickery? and if so is there a library that can be taken to do this?

Community
  • 1
  • 1
RoughPlace
  • 1,111
  • 1
  • 13
  • 23

4 Answers4

2

There is a html tag named Code , You can use it and CSS to create yours code block.

for example :

<html>
<style>
code
{
   background-color : gray;
   padding : 5px;
}
</style>
<body>
<code>Your code here</code>
</body>
</html>
Ali Foroughi
  • 4,540
  • 7
  • 42
  • 66
1

Yes it's all done via CSS. Here is a blog post that should help you.

Ross Dargan
  • 5,876
  • 4
  • 40
  • 53
0

To have code render on an HTML page you need to wrap it in a <code> tag.

The better approach is to combine it with a <pre> tag as well so that you indentation and spacing formatting is retained as well.

<pre>
<code>
    Your code here
</code>
</pre>
Colin Pear
  • 3,028
  • 1
  • 29
  • 33
0

There are lots of projects that will do this. One that I know of is on CodePlex called "ColorCode" which can color your code (by formatting it as HTML). You can append the output to a document:

http://colorcode.codeplex.com/

Matthew Layton
  • 39,871
  • 52
  • 185
  • 313