如果代码的格式(空格,换行,缩进)很重要,请将该pre元素与code元素结合使用:
<pre> <code> x = 42 if x == 42: print "x is … … 42" </code> </pre>
你仍然需要转义特殊含义的字符的HTML(如<用<),所以显示的HTML代码(块<p>This is a paragraph.</p>),它看起来是这样的:
<pre> <code> <p>This is a paragraph.</p> </code> </pre>