Wednesday, November 11, 2009

How to properly write code in blogger blog post? (Part 2/2)

Writing code in post part 2/2.
In first part we told you how to write html/javascript code in blogger blog post. In this part we will show you how to properly write the code in post i.e. how to make your code standout the regular text.
write html/javascript code in blogger blog postAfter you have placed your code in the post, highlight it so that users can easily spot it. Often while reading others post I have face this peculiar problem. The authors do not highlight their code. This is specially problematic when they are referring to a single line of code. You can apply a lot of styles make it bold, increase or decrease font, change the font altogether... Pretty old stuff...isn't it. This is how we like it.





Consider this (Style 1)

//your code here

Or this (Style 2)

//your code here

Or even this... (Style 3)

Title here

//your code here


Neat code presented elegantly. Read on to know how to apply these styles.

Code container style 1
  1. Copy the code
  2. /* Code container by http://bloggerfunda.blogspot.com */ .codecp{ border: rgb(79,129,189) 1px dotted; background-color:#efefef; padding: 3px; min-width: 98%; }
  3. Goto your template. Dashboard > layout > Edit HTML
  4. Search the line (just ctrl+f it).
  5. ]]></b:skin>
  6. and immediately above it paste the code copied in step 1.
  7. Save your template.
Now whenever you have to use this container in your post, write it as follows
<div class='codecp'>
//your code goes here
</div>
For e.g. if you are writing <html></html>, you need to write it as
<div class='codecp'>
&lt;html&gt;&lt;/html&gt;
</div>

Code container style 2
  1. Grab the image from here and upload it to your mydatanest account. Make sure you keep the image access public. Copy the hotlink url.
  2. Replace url of image here text in the code below with url of image uploaded in step 1.
  3. Copy the above modified code.
  4. Goto your template. Dashboard > layout > Edit HTML
  5. Search the line (just ctrl+f it).
  6. ]]></b:skin>
  7. and immediately above it paste the code copied in step 3.
  8. Save your template.
Now whenever you have to use this container in your post, write it as follows
<div class='codes'>
//your code goes here
</div>
For e.g. if you are writing <html></html>, you need to write it as
<div class='codes'>
&lt;html&gt;&lt;/html&gt;
</div>

Code container style 3
  1. Grab the image from here and upload it to your mydatanest account. Make sure you keep the image access public. Copy the hotlink url.
  2. Replace url of image here text in the code below with url of image uploaded in step 1.
  3. Copy the above modified code.
  4. Goto your template. Dashboard > layout > Edit HTML
  5. Search the line (just ctrl+f it).
  6. ]]></b:skin>
  7. and immediately above it paste the code copied in step 3.
  8. Save your template.
Now whenever you have to use this container in your post, write it as follows
<div class='code'>
<p>Title here</p>
<div>
<code>
//your code here
</code>
</div>
</div>
For e.g. if you are writing <html></html>, you need to write it as
<div class='code'>
<p>HTML example</p>
<div>
<code>
&lt;html&gt;&lt;/html&gt;
</code>
</div>
</div>

6 comments:

  1. Very useful post. I was searching a lot about how to show source code, before I settled on my format. I like the input boxes. That's also a good alternative sometimes to display code.

    ReplyDelete
  2. why this is not working on my blog http://techstap.blogspot.com/

    help admin please

    ReplyDelete
  3. hai frnd ...i need some help .if i want to dispaly my code with color for all post how can i do it..

    ReplyDelete

Newer posts Older post Home
 

Recent Posts

| © 2009 BloggerFunda.blogspot.com | Template by Blogger | Enhanced By Abhishek Kumar |
| Site best viewed in Firefox@1024X768 or higher resolution. |