How to show html code in examples

  • Hiei
  • Beginner
  • Beginner
  • Hiei
  • Posts: 51

Post 3+ Months Ago

i've started a site which teaches html and i want to display html code in my examples but they won't show up, i tried using the <pre> tags but they don't work. the code examples i want to show is
the doctype the html and title tags. is it the code i want to show causing the <pre> tags not to work? thanks alot for the help
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Instead of the less than / greater than symbols <> use the ASCII code: &lt; for < and &gt; for >
  • Hiei
  • Beginner
  • Beginner
  • Hiei
  • Posts: 51

Post 3+ Months Ago

nope that does not work . that just shows the <pre> tags in the document. thanks anyways
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

please post your code in the code tags, i cant tell if you posted code or not, your text looks different in someplace and im guessing there is code there thanks.
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

and by the way you use back slash to not exicute a tag
Code: [ Select ]
\<

not
Code: [ Select ]
/<
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Hiei wrote:
nope that does not work . that just shows the <pre> tags in the document. thanks anyways


THe &lt; and &gt; should work. In fact I just use the &lt; so for my website if I want to show the example code for a paragraph:

Code: [ Select ]
&lt;p>
  Text for the paragraph
&lt;/p>
  1. &lt;p>
  2.   Text for the paragraph
  3. &lt;/p>


Then wrap the whole lot in <pre></pre> tags, so the whole thing looks like this:

Code: [ Select ]
<pre>
&lt;p>
  Text for the paragraph
&lt;/p>
</pre>
  1. <pre>
  2. &lt;p>
  3.   Text for the paragraph
  4. &lt;/p>
  5. </pre>


SpooF, I don't think the backslash is an escape character in html, I just tried it ant it just shows as plain text, it doesn't affect the tag.


//edit now i see what you are getting at, the <pre>'s you posted don't show up because you did not dissable html in the post.

What you need to do is use the pre tags as normal, but then use the &lt; for the example code, as per the code I posted above.
  • ATNO/TW
  • Super Moderator
  • Super Moderator
  • User avatar
  • Posts: 23456
  • Loc: Woodbridge VA

Post 3+ Months Ago

Right rtm described what I'm talking about perfectly (I too missed the pre codes at first - I fixed those posts so they show up now).


The easiest way to approach this is paste the code you want to use in the tute into a word processor, and then use find & replace to instantly convert all the <> to &lt; and &gt; Takes about 5 seconds to do a whole document that way.
  • conorific
  • Proficient
  • Proficient
  • User avatar
  • Posts: 350
  • Loc: NY

Post 3+ Months Ago

You could also insert the html code into a textarea:
Code: [ Select ]
<textarea>HTML CODE HERE</textarea>


Another tag I used to use:
Code: [ Select ]
<xmp>HTML CODE HERE</xmp>


It makes it show up in plain text.
  • Hiei
  • Beginner
  • Beginner
  • Hiei
  • Posts: 51

Post 3+ Months Ago

thanks alot everyone for the help, cono's xmp tag helped me and now it displays the code perfectly, thanks again for the help everyone
  • conorific
  • Proficient
  • Proficient
  • User avatar
  • Posts: 350
  • Loc: NY

Post 3+ Months Ago

Hey, not a problem.
  • Hiei
  • Beginner
  • Beginner
  • Hiei
  • Posts: 51

Post 3+ Months Ago

now its not working again, i used everything you guys suggested and they don't work. i don't understand whats happening, the code im want to show is below

Code: [ Select ]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>sample</title>
</head>
<p>you can write anything in between these tags. </p>
</html>
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>sample</title>
  5. </head>
  6. <p>you can write anything in between these tags. </p>
  7. </html>
  • conorific
  • Proficient
  • Proficient
  • User avatar
  • Posts: 350
  • Loc: NY

Post 3+ Months Ago

Between the head tag and the first p tage, you need [body]. Replace [] with <>. You need [/body] for between the ending p tag and the ending html tag, replace like the other one. I hope that was a mistake, otherwise you shouldn't be running an HTML help site.
  • kirtok
  • Born
  • Born
  • kirtok
  • Posts: 2

Post 3+ Months Ago

Hi everybody
This forum is extremely helpful and I just became a member :) I have a PHP script I am working on. User inputs Ebay Auction numbers at the left menu and when submits it, the preview shows up in an iframe at the right side. I would like to be able to show also html source for users to copy and use it. Since there's not an html generated until they hit the submit, how may I supposed to create html source. I would like to show it just below Preview Iframe, it can be another iframe, layer or table. here's the link to my code, it's not completed yet :)
http://www.kirtok.com/ebay/cross/cross3.php
Thanks in advance.
Matt
  • kirtok
  • Born
  • Born
  • kirtok
  • Posts: 2

Post 3+ Months Ago

Hi again
Nobody has any idea??? I really need help with this.
Thanks again
  • Mas Sehguh
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1853

Post 3+ Months Ago

aoeu
  • SpooF
  • ٩๏̯͡๏۶
  • Bronze Member
  • User avatar
  • Posts: 3422
  • Loc: Richland, WA

Post 3+ Months Ago

kirtok you need to make your own topic and make it in the right forum.
http://www.ozzu.com/forum33.html

Post Information

  • Total Posts in this topic: 16 posts
  • Users browsing this forum: No registered users and 87 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.