0

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

Edited by NewOrder: n/a

3
Contributors
7
Replies
8
Views
6 Years
Discussion Span
Last Post by NewOrder
0

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.

Edited by drjohn: n/a

Votes + Comments
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?

1

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>
Votes + Comments
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.

Edited by drjohn: n/a

0

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..

Edited by NewOrder: n/a

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.