Formatting code blocks in a WordPress blog
May 12th, 2010
No comments
I haven’t found a way I really love to present code in a fixed width WP layout, but the one I use is workable. It produces code that looks like this:
It uses a <code> inside a <pre> with a scrolling option to:
- preserve indentation
- use a special font in a quote box to differentiate from other text
- provide a scroll bar, as code invariably goes past the fixed width
Here is the code (ironically described inside itself):
<pre style="overflow-x: scroll; padding: 10px;"><code>[Your code here]</code></pre>
Recent Comments