Friday, March 02, 2007

White Space Ate my Poems

Do you ever get frustrated by not being able to use multiple spaces in your blog? This can be annoying when you're writing or citing a poem which uses lots of spacing in a very controlled manner.

A way around this is to add the white-space CSS property to your template. You can add the following code to your #main identifier:

white-space:pre;

However, you will then have to be careful, since every space will be accepted in every post you make. More sensible is to create a new class in your template:


.allow-whitespace {
white-space:pre;
}


Then, when you write your post, use spaces as you would in a normal word processor, and surround the text which needs the white space either with a div tag with your new class or a span tag. for example:

This text doesn't need white space.



<div class="allow-whitespace"> But this one does</div>


Produces:

But this one does

You can replace the div with span but it's probably not necessary........


This CSS property is compatible with IE5.5 and above, and all of the better browsers out there too.

0 Comments:

Post a Comment

<< Home