how do i show an html code without having it in affect.
im making a preview for a myspace layout and i want to give them the code for the layout but how would i give it to them without having it be in affect?HTML Coding Question..?
Use:
%26lt;pre%26gt; [HTML source code] %26lt;/pre%26gt;
Or:
%26lt;textarea%26gt; [HTML source code] %26lt;/textarea%26gt;HTML Coding Question..?
That is not the correct answer. Can't use HTML in textarea tags without de-activating it. Why must people be so quick to think that people know what they are doing in some of these answers when you have a pro coder giving you your answer?
Ron Report Abuse
Guess everyone has been learning from my canned answer to this type question. LOL
How to put HTML code in a textarea or scroll box so it can be copied/pasted:
You MUST deactivate the HTML code by making it appear as text in whichever box you use. The code I show below WILL work as it's been tested.
Change all the opening tag symbols, ';%26lt;';, to the character entity, %26amp; lt ; (without spaces). %26amp; lt ; (without spaces) = %26lt;. This will deactivate the HTML code in the textarea/scroll box, but allow users viewing the page to copy/paste the code.
Example:
%26lt;textarea style=';background: transparent;'; rows=';8'; cols=';70';%26gt; %26amp; lt;img style=';width: XXpx; width: YYpx; border: 0; src';pic link'; alt=';Text Description';%26gt; %26lt;/textarea%26gt; There is no closing tag for the image tag unless you are using an XHTML DocType then the image tag is closed with a space and a ';/';:
Example:
%26amp; lt;img style=';width: XXpx; width: YYpx; border: 0; src';pic
link'; alt=';Text Description'; /%26amp;' gt;
%26amp;' lt; without spaces = %26lt;%26amp;' gt; without spaces = %26gt;
Ron
open notepad or wordpad (preferred) use the replace under edit. Type %26lt; in the find and %26amp; l t ; (no spaces and semicolon at the end) in the replace. Then click replace all. Do the same for %26gt; and %26amp; g t ; (be sure to include semicolon)
In an html page these will display normally but won't affect code. GT stands for greater than and LT stands for less than. These are character symbol codes.
Just convert all your ';%26lt;'; and ';%26gt;'; symbols into html entities. For ';less than'; use %26amp;lt; and for greater than use %26lt;strong%26gt;%26amp;gt;%26lt;/strong%26gt;
An example would be:
%26amp;lt;html%26amp;gt;
%26amp;lt;/head%26amp;gt;
%26amp;lt;title%26amp;gt; My title%26amp;lt;/title%26amp;gt;
%26amp;lt;/head%26amp;gt;
%26amp;lt;body%26amp;gt;
%26amp;lt;p%26amp;gt;
hello :)
%26amp;lt;/p%26amp;gt;
%26amp;lt;/body%26amp;gt;
%26amp;lt;/html%26amp;gt;
You could comment out the code %26lt;!--code goes here--%26gt;
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment