tags:

views:

34

answers:

3

Within a standard code block, should HTML appear exactly as written?

For example, if I put the following:

<code>
<script type="text/javascript">Something in javascript</script>
</code>

Should it appear exactly as above?

I assume the code button here on stackoverflow is doing something else other than just putting it in ?

Thanks!

A: 

No. <code> isn't even block-level. It also depends on whether you mean "traditional" HTML or XHTML.

tc.
+1  A: 

To make tags appear as they are use the <pre> tags instead:

<pre>
  <script type="text/javascript">Something in javascript</script>
</pre>
Sarfraz
+2  A: 

There are certain characters that must be encoded even in the code block. My preference is converting the less than, greater than and ampersand. This handles most of the code.

Dave