Wordpress code/pre tags

less than 1 minute read

More things for posterity, as I had to search several times to find what I wanted…

To make the pretty formatting boxes for command output in the Grails post I just finished, I had to use both pre and code tags, like this:

<pre><code>[content here]</code></pre>

If I just used pre the font was monospace but huge, and if I just used code it stopped after the first blank line and the rest was just text. I could probably adjust this in the CSS of the theme or something, but whatever, I’ll just take the simpler path. I also had to reformat some of the longer lines because they were jutting out of the code box. Some still will if you’re using a really skinny browser window, but that’s your problem, get a bigger screen. ;)

I found this post useful in figuring the pre/code formatting stuff out.