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

HTML <code> tag not working as expected.

Hello folks.

I'm taking notes and wanted to display some code but only this is being displayed:

< a href="my_directory/another_page.html">My Directory Link

...Which is most of it but why wont the closing anchor '</a>' appear?

Here's what I wrote.

<p>To Link back OUT of a folder we can use <strong>'../'</strong><br>
Example:<code><a href="../index.html">Back Out of Directory Link</a></code></p>

Thanks for your time:) Dan

3 Answers

You musn't make spaces in begining of an anchor --> not "< a" (anchor + space + a) but"<a" (anchor + a) :) ..... without spaces...

If you try to use text editor(sublime text) it shows you this error ;)

I hope this helps you

Hi Ales, Thanks for that. Yes, you're quite right, however this just results in me getting the Link itself and not the code which I wanted displayed.

:S

Hi Daniel, Sory for misunderstanding... I didn't catch the question right :)

Now, if understood what you mean, here is the answer ( you can just copy paste it and it should work)

<code><a href="../index.html">Back Out of Directory Link</code></p>

To display the code in your browser you replace signs with special characters: < (less than) , > (greater than).

With this you replace < and > with < (less than) and > (greater than).And after each special character you put semicolon so that browser knows when the char ends.

Hope this resolve your question :)

< >

<code><a href="../index.html">Back Out of Directory Link</code></p>

I'm sorry but i can't show code here ...so I try one more time ..

you use & l t ; (you must write without spaces) for < and & g t ; (without spaces) for < .. .and then it will show you as a code

Hi Ales

Thanks for being keen on answering. I'm aware of those steps already. I just thought I could wrap any text in code without using the ampersand (&) and semicolon (;).

Shame we can't code in replies.

Cheers Dan

Hi Daniel...

Well,there is one other option:

Enclose the html code between xmp tags: .... < xmp > , < /xmp > (without spaces of course)

example: (i hope it will show it right) ;)

<xmp><b> this is bold </b></xmp>

Daniel Macleod - Check out how to type code on the forum for details on how to get the forum software to correctly format your code in your replies.

Cheers James,

I'm on it;)