WordPress.com <code> bug

It turns out that in the hosted WordPress.com solution, if you use the <code> tag you have to make sure that the body of that tag (the stuff between the start and end tag) doesn’t include any blank lines. Otherwise the WP WYSIWYG editor will “trim” the <code> tag to the end of the line immediately preceding the first blank line.

What if you want blank lines for sexy, good-looking code listings? Just add an &nbsp; in place of the blank line, as follows:

private void Foo() { // body of Foo }
&nbsp;
private void Bar () { // body of Bar }

This will show up as:
private void Foo() { // body of Foo }

private void Bar () { // body of Bar }

Also, if you want to edit your custom CSS and add a border or background-color attribute to the <code> tag you’ll need to make sure to add the style:

display:block;

to your code {} class or else you’ll get those weird inline style effects that look so professional!

0 Responses to “WordPress.com <code> bug”



  1. Leave a Comment

Leave a comment




TwitterCounter for @anthonyrstevens
Add to Technorati Favorites

RSS Feed

View Anthony Stevens's profile on LinkedIn