how do i use code in html (i use dreamweaver)

when i put a code ..what i get on my page:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{ class Program
{ static void Main(string[] args)
{ Student student = new Student();
student.Name = "Dani";
student.Score = 200;
Console.WriteLine(student.Name);
Console.WriteLine(student.Score);
Console.WriteLine("======");
Person person = new Person();
person.Name = "Oleg";
Console.WriteLine(person.Name);
} }

/> }
class Person
{
public string Name { get; set; }
}
class Student:Person
{
public int Score { get; set; }
}

but i want to put identation like i can do in this site using :

CODE][/CODE

how do you do it in html

Like this

<pre><code>//Do a bit of code debugging     ||-- Check Array vals
  document.write ("&lt;ul&gt;");
  for (i=1;i&lt;array.length;i++)
   {
      str += "&lt;li&gt;Value of array " + i + " is: " +array[i] + "&lt;/li&gt;";
   }
  document.write(str);
  document.write ("&lt;/ul&gt;");
</code></pre>

<pre> is for pre-formatted stuff and retains the white space that html normally just discards. The numbers are just added by THIS forum. toggle to plain text view, to see how it looks in your own code.

commented: Awesome it worked +0

can you also tell me, how to wrap the whole square in some box, that could be useful to segregate the codes appearance?

Put the whole square in a DIV. You can style a DIV pretty easily.

<div><pre><code>
...
</code></pre></div>

sorry solid. but div does nothing when i wrap the whole thing in it

div by itself does nothing. you need to style the div using various attributes to obtain the look you want. For example (use CSS style instead of this inline, but you get the idea here):

<div style="background-color:#ebe6cf;border: 1px solid #000;"><.....></div>
commented: thanks +0

First, use an external stylesheet.
Then give the name a class - whatever name makes sense to you. eg .myCode
Give the div a width and a border, in the external style sheet.

Suggest you read up on css.

i am a complete beginner, what i want to do is to put a piece of code into a box!!

alright, i got it ! may be a should skip the box bit for now ,cause i am not too advanced..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.