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,021
  • 12
  • 21

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,480
  • 7
  • 40
  • 66
1

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

Ross Dargan
  • 5,826
  • 4
  • 37
  • 52
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
  • 2,968
  • 1
  • 27
  • 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
  • 35,375
  • 44
  • 163
  • 278