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!

Advertisements

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



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s





%d bloggers like this: