Results 1 to 2 of 2

Thread: How to show HTML code

  1. #1
    Join Date
    Jun 2008
    Posts
    1

    How to show HTML code

    I would like to display HTML code in a text box for people to copy and paste.

    I've tried several methods, including <pre><code>; the "&amp," etc. language; and <textarea>

    I've had the best luck with <textarea>, but viewers copying and pasting only works in Mozilla--not Internet Explorer.

    Please help!

  2. #2
    Join Date
    Feb 2006
    Location
    Salisbury UK
    Posts
    4,332
    You need to use special character codes as shown here:-
    http://www.tedmontgomery.com/tutorial/HTMLchrc.html
    definitely for the < at the beginning of every tag; some people say every > closing tag but I've found it unnecessary.

    so instead of <div>........</div> in your code you type &lt;div>.........&lt;/div> and it shows in the web page as <div>........</div> instead of being operated as code by the browser and viewers can copy/paste it.

    Remember to do it at the beginning of every tag.

    There is an online code converter here if you have a lot to convert:-
    http://www.tutorialtastic.co.uk/converter.php

    If you put <code>.............</code> tags around your converted code it will dispaly as a different font-family to show that it is code. You can style the code tag if you want:-

    code { font-family: monospace; color: red; }
    Last edited by Wickham; 03 Jun 2008 at 03:24 PM.
    Code downloaded to my PC will be deleted in due course.
    WIN7; IE9, Firefox, Opera, Chrome and Safari for Windows; screen resolution usually 1366*768.
    Also IE6 on W98 with 800*600 and IE8 on Vista 1440*900.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •