Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make html ignore code that is part of text?

Tags:

html

I need to include some codes in my html document

I've tried <pre> tag, but that didn't help.

How do I get this code into a document like text?

Thanks

like image 351
Tarek Saied Avatar asked Jul 09 '11 05:07

Tarek Saied


2 Answers

Short Answer.

Encode your code using an online HTML Encoder and then put it inside pre

<pre>
    <%--your encoded code goes here--%>
</pre>

Long Answer.

The above will only help you to show your code. If you want proper highlighting for your code, Try something like SyntaxHighlighter

Link: How to use SyntaxHighlighter.

like image 175
naveen Avatar answered Oct 06 '22 20:10

naveen


You have to use html entities. Example:

<div>
   Some Stuff
</div>

should be

&lt;div&gt;
   Some Stuff
&lt;/div&gt;

and it will render as the first one

like image 23
Ibu Avatar answered Oct 06 '22 19:10

Ibu