Pregunta

I have some html that uses a few "pre" tags to preserve code snippets, using "html" as the lang. For the most part, it works, but in one specific instance, namely:

<pre lang="html">
    <li><a runat="server" href="~/Images">Images</a></li>
</pre>

Instead of preserving the snippet, it shows a bullet and a hyperlinked "Images" - what the deuce?

The whole shebang can be seen, malformed, beneformed, and/or mutilated at: http://jsfiddle.net/7BSLc/

¿Fue útil?

Solución

<pre> is for telling the browser to keep white space formatting and doesn't tell the browser not to render html elements within. you need to encode the html you're trying to put in. You can use encoded values for the angle brackets &lt; and it will render the html as text instead of randering the html. http://jsfiddle.net/7BSLc/9/

Otros consejos

It is ugly, but it works:

&lt;li&gt;&lt;a runat="server" href="~/Images"&gt;Images&lt;/a&gt;&lt;/li&gt;

HTML-Elements are interpreted within pre-elements! You should use HTML-entities for HTML-specific chars.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top