1

i put following lines in header of html

<link href="http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.css" rel="stylesheet" type="text/css" />
<script src="http://twitter.github.com/bootstrap/assets/js/google-code-prettify/prettify.js" type="text/javascript"></script>

and in html i want to hightlight some html code :

<body onload="prettyPrint()">
    <pre class="prettyprint lang-html">

           <input type="button" value="HELLO"/>

</pre>
</body>

but i am not unable to hightline html code : current copy here : http://jsfiddle.net/jTYQk/

2
  • I don't understand, what are you trying to highlight? The Button? Commented Sep 27, 2012 at 11:02
  • this line : <input type="button" value="HELLO"/> Commented Sep 27, 2012 at 11:06

1 Answer 1

1

The pre element does not stop the browser from rendering internal elements. http://www.htmlcodetutorial.com/linepar/_PRE.html

By changing your < to &lt; and > to &gt;, you will get it to render correctly. Check http://jsfiddle.net/jTYQk/1/ for an example.

OR

You could also wrap your code in <xmp></xmp>. See it at http://jsfiddle.net/jTYQk/2/ .

However, this is not recommended since xmp has been marked obsolete. See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/xmp

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.