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 {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.
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 */
}
[update]
I've added word-wrap:normal, because of good old IE;
1 comment:
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.
Post a Comment