Friday, May 21, 2010

HTML Help plz?? I need to put coding in a box but just the actuall coding itself?

I'm making a a site for layouts but i need to put the coding in a scroll box without the acctual layout showing up in the box. does anyone know how to make sure the coding only shows up as coding? If you could please post the code or walk me through it, that would be great

HTML Help plz?? I need to put coding in a box but just the actuall coding itself?
I think you just do %26lt;code%26gt;Words here%26lt;/code%26gt; I think?
Reply:Goto the following link:





http://javascript.internet.com/





Select any program. Do a right click, view source, save the file. Look at the file and you will see code with %26amp;it's and %26amp; gt's before and after statments you want. These will display as text lines within your box window as follows.





%26amp;it HEAD %26amp; gt





will produce the following





%26lt;HEAD%26gt;





The "%26amp;it" produces the %26lt; symbol, the "%26amp; gt" produces the %26gt; symbol as outputs. For this show-n-tell I had to add a space between the "%26amp;" and the "gt" at the end or else it would do just as it is told to do, show a %26gt;.





With a little study you can see how it is done. Below is just a small snippet without the %26amp; codes showing up.





%26lt;TEXTAREA cols=75 name=txt rows=20 wrap=VIRTUAL%26gt;


%26lt;!-- This script and many more are available free online at --%26gt;


%26lt;!-- The JavaScript Source!! http://javascript.internet.com --%26gt;


%26lt;/TEXTAREA%26gt;





Hay, this turned into quite a task just writeing it so you can see how it was done.
Reply:I've come across that problem myself. The idea solution would be to use the %26lt; xmp %26gt; tag. However, the XMP tag is deprecated meaning it may not be supported nowadays since it is no longer a web standard tag. Another way is to use the PRE tag, but that is not identical to the XMP tag in that it still processes tags. Use the PRE tag if you want to attain whitespace. The CODE tag doesn't seem to do the trick either. The best way is to replace all the %26lt; with %26lt; and the %26gt; with %26gt; which stand for Less Than and Greater Than.





Here's an example:


%26lt;html%26gt;


%26lt;body%26gt;





%26lt;div style="width:100px; height:100px; border:black 1px solid; overflow:scroll;"%26gt;


%26lt;pre%26gt;


Here is my code %26amp; lt;a href="google.com"%26amp; gt;Google%26lt;/a%26amp; gt;%26amp; lt;br /%26amp; gt;%26amp; lt;p%26amp; gt;Lallala%26amp; lt;/p%26amp; gt;


Here is my code %26amp; lt;a href="google.com"%26amp; gt;Google%26lt;/a%26amp; gt;%26amp; lt;br /%26amp; gt;%26amp; lt;p%26amp; gt;Lallala%26amp; lt;/p%26amp; gt;


Here is my code %26amp; lt;a href="google.com"%26amp; gt;Google%26lt;/a%26amp; gt;%26amp; lt;br /%26amp; gt;%26amp; lt;p%26amp; gt;Lallala%26amp; lt;/p%26amp; gt;


Here is my code %26amp; lt;a href="google.com"%26amp; gt;Google%26lt;/a%26amp; gt;%26amp; lt;br /%26amp; gt;%26amp; lt;p%26amp; gt;Lallala%26amp; lt;/p%26amp; gt;


Here is my code %26amp; lt;a href="google.com"%26amp; gt;Google%26lt;/a%26amp; gt;%26amp; lt;br /%26amp; gt;%26amp; lt;p%26amp; gt;Lallala%26amp; lt;/p%26amp; gt;


%26lt;/pre%26gt;


%26lt;/div%26gt;





%26lt;/body%26gt;


%26lt;/html%26gt;





NOTE: I had to add a space in between the %26amp; and the lt (or gt) in order to display it on this page without it turning into the %26lt; or %26gt; respectively. If you're planning to incorporate some PHP into this (let's say you're making a posting page where people can display their code), you can use PHP to replace all %26lt; with the %26amp; lt; and so on.





Hope I didn't confuse you too much! Good luck!


No comments:

Post a Comment