A guide to displaying code snippets box on your Blogger website using Prism.js.
Do you know the most effective way to display code snippet box correctly on Blogger's websites or any other webpage and make them look awesome?
Code Box features include :
- Black background theme
- Show Line Numbers
- Auto language detection
- Keyword highlighting
- Auto code formatting
- Normalize Whitespace
- Copy to Clipboard Button
- Matching braces with colors
Basics requirements to understand:
- HTML (compulsory)
- CSS (Optional)
- JavaScript (Optional)
In this tutorial, I will show you the best ways to display code snippets box on Blogger's websites or any other webpage, using examples and I'll provide source code.
What is the purpose of displaying code snippets box on a web page?
You can display code snippets in HTML to share your programming knowledge with your audience.
If you write a code example guide on your blog or any web page.
To demonstrate parts of this code snippets in your web page with the proper format and styling. It will be necessary to present them that way.
Requirement to use code snippets box on your web page.
You just need javascript and CSS files from prism js. Do not worry about any files. All the code you need to add a code snippets box to your website is given below step by step. Just copy and paste. If you are a beginner, don't figure out PrismJS. Copy and paste the code below.
The list of top encoder tools is:
- https://jackstromberg.com/html-encoder-decoder/
- https://opinionatedgeek.com/Codecs/HtmlEncoder
- https://10015.io/tools/html-encoder-decoder
- https://www.online-toolz.com/tools/html-decode.php
- https://www.w3docs.com/tools/html-encoder/
- https://codebeautify.org/html-encode-string
- https://mothereff.in/html-entities
Don't forget to encode the original code.
1. PrismJS css file:
Copy the code below by clicking the copy button. And paste it into your project. If you want custom CSS, see the official docs at PrismJS.com
<link href="https://cdn.jsdelivr.net/gh/janak0ff/codebox-for-web-page@master/prism.min.css"
rel="stylesheet"> </link>
2. PrismJS JavaScript file.
Copy the minified JS code below by clicking the copy button. And paste it into your project. If you want custom Javascript, see the official docs at PrismJS.com
<script src="https://cdn.jsdelivr.net/gh/janak0ff/codebox-for-web-page@master/prism.min.js"></script>
3. Html code contains <pre> and <code>.
NOTE: In the yellow highlighted area, you have to type the extensions of the language. For example txt for Plain text, py for python, java for java language, js for JavaScript, CSS for CSS, HTML for HTML Markup language, sass for sass, PHP for PHP. For more visit PrismJS.com
<pre><code class="language-html line-numbers match-braces rainbow-braces" data-prismjs-copy="Copy">
{Place all type of language code right here. }
</code></pre>
4. Final combined code html, css, and JavaScript.
Our final code looks like this. You can copy and paste directly into your projects. This is all about the project's resources. Html code (Need to encode).
<html>
<head>
<link href="https://cdn.jsdelivr.net/gh/janak0ff/codebox-for-web-page@master/prism.min.css" rel="stylesheet">
</link>
<title>Code box</title>
</head>
<body>
<pre><code class="language-html line-numbers match-braces rainbow-braces" data-prismjs-copy="Copy">
{ All your displaying code snippets on a web page }
</code></pre>
<script src="https://cdn.jsdelivr.net/gh/janak0ff/codebox-for-web-page@master/prism.min.js"></script>
</body>
</html>
5. Examples of different language.
I’m JANAK! Currently attending JMC for a BCA program. My +2 was completed at Pentagon International College in the science stream (Physics).
A passionate self-taught Web developer with a couple of years' experience, I aim to become a Full Stack Developer and programmer.
In my spare time, I blog and upload videos about various technologies. I began coding and frontend development as a hobby and have designed
and implemented beautiful backend and frontend systems using different JavaScript frameworks. I enjoy designing and developing user interfaces,
testing, debugging, writing, learning, and discussing the latest technologies. I am also familiar with Debian Linux. I have experience of website
design, building, and customization, as well as WordPress knowledge. Learning new coding skills and researching relevant technical knowledge is a
pleasure for me, as is creating simple, effective, and intuitive designs to solve complex problems.
Stay connected with us.
class Solutionjaank{
public static void main(String []argh){
Scanner in = new Scanner(System.in);
int t=in.nextInt();
for(int i=0;i<t;i++){
int a = in.nextInt();
int b = in.nextInt();
int n = in.nextInt();
for(int j = 0; j < n; j++){
a = a + (int)Math.pow(2,j)*b;
System.out.print(a + " ");
}
System.out.println("");
}
in.close();
}
}
# Python program to find the sum of natural using recursive function
def recur_sum(n):
if n <= 1:
return n
else:
return n + recur_sum(n-1)
# change this value for a different result
num = 16
if num < 0:
print("Enter a positive number")
else:
print("The sum is",recur_sum(num))
person.getPersonInfo = function () {
let skillsWithoutLastSkill = this.skills
.slice(0, this.skills.length - 1)
.join(', ')
let lastSkill = this.skills.slice(this.skills.length - 1)[0]
let skills = `${skillsWithoutLastSkill}, and ${lastSkill}`
let fullName = this.getFullName()
let statement = `${fullName} is a ${this.title}.\nHe lives in ${this.country}.\nHe teaches ${skills}.`
return statement
}
console.log(person)
console.log(person.getPersonInfo())
.spikes {
position: relative;
background: #2c3e50;
height: 50vh;
}
.spikes::after {
content: '';
position: absolute;
right: 0;
left: -0%;
height: 50px;
background-size: 50px 100%;
background-image: linear-gradient(135deg, #2c3e50 25%, transparent 25%), linear-gradient(225deg, #2c3e50 25%, transparent 25%);
background-position: 0 0;
}
5. Steps to use code snippets box.
In this tutorial I'll show :
- In blogger's websites.
- In normal web pages or HTML pages
<pre><code class="language-html line-numbers match-braces rainbow-braces" data-prismjs-copy="Copy">
{ your code to display on blogger }
</code></pre>
<link href="https://cdn.jsdelivr.net/gh/janak0ff/codebox-for-web-page@master/prism.min.css" rel="stylesheet">
</link>
<script src="https://cdn.jsdelivr.net/gh/janak0ff/codebox-for-web-page@master/prism.min.js"></script>
Step 2: Open you bloggers dashboard and click +NEW Post![]() |
| Click Html view |
![]() |
| Paste code here and publish you posts. |
![]() |
| Final post looks like this. |
<pre><code class="language-html line-numbers match-braces rainbow-braces" data-prismjs-copy="Copy">
{ your code to display on website }
</code></pre>
Example:






