Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Putting HTML code in a <code> tag [SOLVED]

I am trying to make a website that includes an HTML example like this:

<code>
<!—Should be an indent…—><p>Hi</p>
</code>

But when I do that in an HTML document see here it renders as the HTML code. :(

Any thoughts are appreciated

3 Answers

The only real way to do this (without JavaScript) is to replace all of your opening tags with &lt;, like this:

 &lt;p>Hi&lt;/p>

which will be rendered to:

<p>Hi</p>

in browsers.

Thanks! That works

Hello,

For some reason this form isn't letting me show you exactly how. You use the less than and greater than markup and put the tag (such as div or p) in the middle. Your answer is on this site: http://www.w3schools.com/html/html_entities.asp

Thanks!

Ryan is right put <p>Hi</p>

ok. Thanks!