Problem with <pre> </pre>

dpinto04
dpinto04 used Ask the Experts™
on
I'm trying to use the code below in a web page and want the line to appear as it is below so viewers can see it.

<pre>
document.write('<script src="my_file.js" type=text/javascript></script>');
</pre>

But the output on screen gives me only

document.write('')

What am i doing wrong here?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
dpinto04,

The pre tag does not mean that the browser will ignore special characters.  In fact you may not even need the pre tag if that is why you were using it.  Are you using a server language to write this page?  If so they normally have a function that will automatically change the characters for you.  Otherwise you will need to manually do it.  For example look at the characters and corrections below.

< = &lt;
> = %gt;
"  = %quot;

Let me know if you have any questions or need more information.

b0lsc0tt

Commented:
Text in pre tags will usually preserve spaces and line breaks.  The browser will normally show it in a mono-spaced or fixed-pitch font so it will appear different from the rest.

Author

Commented:
If &quot = " whats it for '
Exploring ASP.NET Core: Fundamentals

Learn to build web apps and services, IoT apps, and mobile backends by covering the fundamentals of ASP.NET Core and  exploring the core foundations for app libraries.

Commented:
' is &apos; for apostrophe.  Another very common on is & = &amp; for ampersand.

Author

Commented:
Thanks. Alls working fine now :-)

Commented:
Your welcome!  I'm glad that I could help.  Thank you for the grade, the points and the fun question.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial