Dec
26th

CSS Style for Code on your Blog

Happy New Year! Marketing Technology finds and reports on the latest technology that will enable your business to effectively market to your audience, for acquisition or retention strategies. Subscribe now the Marketing Technology Blog RSS feed or to the Marketing Technology Email to have new content sent directly to your inbox. You'll also find my other business blog helpful, Social Media Domination.

A friend of mine asked me how I made the code regions on my last blog entry. I actually ‘faked’ the code region utilizing a style. Within Blogger, you can edit your template. I added the following style:

p.code {
font-family: Courier New;
font-size: 8pt;
border-style: inset;
border-width: 3px;
padding: 5px;
background-color: #FFFFFF;
line-height: 100%;
margin: 10px
}

The next step is to edit my tag in the ‘Edit Html’ mode. I simply point to my new style by making the tag. Voila! Breaking down the styles:

  • Set the font to Courier New… looks like a generic code editor
  • Set the font size to 8pt to look right
  • Set the paragraph border style to ‘inset’. This replicates what a textarea looks like on the page.
  • Set the border width to 2 or 3 pixels. This makes the inset border style look right.
  • Padding sets the distance between the border and the text inside.
  • Background color… set it to white (#FFFFFF)
  • Line-height - I adjusted this to 100% because some of the other styles in my blogger theme made my line height about 200%
  • Set the margin to 10 px. This moves the paragraph (p tag) 10 pixels away from everything.

That’s all there is too it! One note: The editor that comes with Blogger isn’t capable of displaying the as it will appear in your blog. But it works and looks great!

One more note… after you make the edit to the tag, the Blogger editor likes to randomly use it elsewhere across your post. It’s a little bit annoying! My advice would be to write your entire post and then make the one small edit afterwards.

One final note… be sure to use HTML Entities to display your symbols! A couple examples:

  • Quotes (”) are “
  • < is <
  • > is >

Happy Coding!

RSS feed | Trackback URI

3 Comments »

Comment by Tarun
2005-12-27 12:59:00

I m just curious to know wheter i could add feeds from a news site so that news appears onto my side bar?
 
Comment by Douglas Karr
2006-01-01 21:33:00

Absolutely. I think the best product I have found out there is TinyRSS:
http://www.codeproject.com/jscript/TinyRSS.asp?df=100&forumid=153526&exp=0&select=1078179
 
Comment by aÅŸk
2007-07-03 09:06:52

i thing there is no need to write now than . you can use helpful editors.you can choose colour ,border etc..
 
Name (required)
E-mail (required - never shown publicly)
URI
Your Comment (smaller size | larger size)
You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.

My Comment Policy: I moderate comments. Please be patient:

  • Spam will happily be destroyed.
  • Use your real name, not some keywords. Otherwise it will be destroyed.
  • Mean comments aren't necessary. If I don't post them I will reply personally to let you know why.
  • Lewd comments will be edited, I don't want my readers leaving because of offensive content.
Great debate, criticism and colorful commentary is always appreciated and approved!