Posts

Showing posts with the label html

Setting default text alignment in blogger html view

Image
By default the text alignment of the blogger is left alignment. But I feel that the justify alignment looks better, and most of the time I write blog using "HTML view" since most of the time I share some kind of source code, which, I feel, is better using html view compared to compose view. So it will be better for me if I can add default text alignment to justify for whole document instead of doing for each paragraph. Here I am sharing how I do it in blogger. Solution One of the easiest way is to use the <style> function in the head secetion of html and setting the body to justify alignment using the body{text-align: justify} . So basically add the following section at the start of the document. <head> <style> body{text-align: justify} </style> </head> Now start writing your post inside the <body> section, the text will be aligned accordingly. Your will look something like thi: <bo...

Syntax highlighting for code in blogger

Introduction: There is no straight forward or simple way to do syntax highlighting to share any code through blogger. But we can easily do that by using some third party service. One such service is highligtjs.org . Use the following steps for code highlighting. Solution: We have to work in html view rather than compose view of blogger. For syntax highlighting we have to first add JS script for importing CSS in the header of the html. To do that add the following line at the starting in the html view. <head> <link rel="stylesheet" href="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/styles/androidstudio.min.css"> <script src="//cdn.jsdelivr.net/gh/highlightjs/cdn-release@10.2.0/build/highlight.min.js"></script> <script>hljs.initHighlightingOnLoad();</script> </head> Then start writing inside the body html tag, as...