Just sharing some of my inconsequential lunch conversations with you... RSS  

Wednesday, December 19, 2007

Blogging source code

There is a lot to consider about blogging source code. There are those who post source code on images and those who post the code itself. Those who post the code itself have probably different strategies about the formating. Finally, there is the flow problem - we had to choose a template large enough to show code at it's width.

I think I've found a good compromise - well, to be honest, I've copied from Hanselman's blog. Here it is:


pre {
background-color:#FCFBF8;
border-color:#CCCCCC;
border-style:solid;
border-width:1px 1px 1px 2px;
line-height:1.2em;
margin:1em auto;
overflow:auto;
padding:1em;
width:90%;
word-wrap:normal; /* IE */
}
Noticed the overflow:auto? What it does is to show the code on all it's width if possible, and automatically pan when no width is available. Cool.

[update]
I've added word-wrap:normal, because of good old IE;

1 comment:

Tiago said...

Thanks Mário.

I'm already using it in my blog.

An important thing also is that you have the "width: 90%". That way the block width never expands beyond your post width.

Development Catharsis :: Copyright 2006 Mário Romano