Experience Certificate Generator in HTML, CSS, and JavaScript


By Faraz -

Learn how to create an Experience Certificate Generator using HTML, CSS, and JavaScript. Build customizable certificates for your organization effortlessly.

Experience Certificate Generator in HTML, CSS, and JavaScript.jpg

Welcome to our comprehensive guide on building an Experience Certificate Generator from scratch, using the power of web development! In today's fast-paced professional world, the need for efficient HR processes is paramount. One such process is the creation of experience certificates for employees, a task that can often be time-consuming and prone to errors.

Imagine a tool that can automate this process, making it not only quicker but also more accurate and professional. That's precisely what we're going to explore in this tutorial. Whether you're an HR professional looking to simplify your workflow or a web developer eager to expand your skill set, this step-by-step guide will take you through the journey of creating your very own Experience Certificate Generator.

We'll delve into the realms of HTML, CSS, and JavaScript to craft a user-friendly and customizable solution. By the end of this tutorial, you'll have the knowledge and tools to streamline the certificate generation process in your organization. So, let's embark on this exciting journey into the world of web development and HR automation!

Source Code

Step 1 (HTML Code):

To get started, we will first need to create a basic HTML file. In this file, we will include the main structure for our Experience Certificate Generator.

After creating the files just paste the following codes into your file. Make sure to save your HTML document with a .html extension, so that it can be properly viewed in a web browser.

Let's break down its structure and elements:

1. <!DOCTYPE html>: This declaration specifies the document type and version of HTML being used. In this case, it's HTML5.

2. <html>: This is the opening tag for the HTML document, and everything within your web page is enclosed within this tag.

3. <head>: Inside the <head> element, you typically include metadata and resources related to the web page, such as the title and external stylesheet.

  • <title>: This tag sets the title of the web page, which appears in the browser's title bar or tab.
  • <link rel="stylesheet" type="text/css" href="styles.css">: This line links an external CSS (Cascading Style Sheet) file named "styles.css" to the HTML document. It's used to style the content of the page.

4. <body>: The <body> element contains the visible content of the web page.

5. <div class="container">: This is a <div> element with a class attribute set to "container." It is often used for layout purposes to group content together.

6. <h1>: This is a top-level heading that displays the text "Experience Certificate Generator" on the web page.

7. <form id="certificateForm">: This is a form element with the ID "certificateForm." It is used to collect information for generating an experience certificate.

  • <label for="employeeName">: Labels are used to provide a description for form input fields. The "for" attribute specifies which input field it's associated with.
  • <input type="text" id="employeeName" required>: This is an input field of type "text" with the ID "employeeName." The "required" attribute makes it mandatory to fill in this field.
  • Similar sets of labels and input fields are provided for "Company Name," "Duration," and "Designation."
  • <button type="submit">Generate Certificate</button>: This is a submit button that, when clicked, will submit the form for generating the certificate.

8. <div id="certificateOutput" class="certificate-preview hidden">: This is a div element with the ID "certificateOutput" and the class "certificate-preview." It's initially hidden (hidden class) and will display the generated certificate later.

  • <h2>: A second-level heading displaying "Experience Certificate."
  • <div id="certificateContent"></div>: This empty div will contain the content of the generated experience certificate.
  • <button id="downloadBtn" class="hidden">Download</button>: This button, initially hidden (hidden class), will allow users to download the generated certificate.

9. <script src="script.js"></script>: This script tag links an external JavaScript file named "script.js" to the HTML document. JavaScript is used to add interactivity and functionality to the web page.

This is the basic structure of our Experience Certificate Generator using HTML, and now we can move on to styling it using CSS.

Step 2 (CSS Code):

Once the basic HTML structure of the Experience Certificate Generator is in place, the next step is to add styling to the generator using CSS.

Next, we will create our CSS file. In this file, we will use some basic CSS rules to style our generator. Let me explain each part of it:

1. .container:

  • max-width: 500px;: This sets the maximum width of the .container element to 500 pixels.
  • margin: 0 auto;: This centers the .container horizontally by setting its left and right margins to auto.
  • padding: 20px;: This adds 20 pixels of padding to the inside of the .container element.

2. h1:

  • text-align: center;: This centers the text within all <h1> elements on the webpage.

3. form:

  • margin-bottom: 20px;: This adds 20 pixels of margin at the bottom of all <form> elements on the webpage.

4. label:

  • display: block;: This makes all <label> elements display as block-level elements, causing them to appear on separate lines.
  • margin-bottom: 5px;: This adds 5 pixels of margin at the bottom of all <label> elements.

5. input[type="text"]:

  • width: 100%;: This sets the width of all text input fields to 100% of their parent container, making them expand to fill the available space.
  • padding: 8px;: This adds 8 pixels of padding to the inside of all text input fields.
  • border: 1px solid #ccc;: This adds a 1-pixel solid border with a color of #ccc (light gray) to all text input fields.
  • border-radius: 4px;: This rounds the corners of all text input fields with a 4-pixel radius.
  • margin-bottom: 10px;: This adds 10 pixels of margin at the bottom of all text input fields.

6. button:

  • background-color: #4CAF50;: This sets the background color of all <button> elements to a shade of green (#4CAF50).
  • color: white;: This sets the text color of all <button> elements to white.
  • padding: 10px 20px;: This adds 10 pixels of padding on the top and bottom and 20 pixels of padding on the left and right to all <button> elements.
  • border: none;: This removes the border from all <button> elements.
  • border-radius: 4px;: This rounds the corners of all <button> elements with a 4-pixel radius.
  • cursor: pointer;: This changes the cursor to a pointer (typically a hand) when hovering over <button> elements, indicating they are clickable.

7. .certificate-preview:

  • margin-top: 20px;: This adds 20 pixels of margin at the top of elements with the class .certificate-preview.
  • border: 1px solid #ccc;: This adds a 1-pixel solid border with a color of #ccc around elements with the class .certificate-preview.
  • padding: 20px;: This adds 20 pixels of padding to the inside of elements with the class .certificate-preview.
  • font-family: Arial, sans-serif;: This sets the font family for elements with the class .certificate-preview to Arial or a sans-serif font.

8. .hidden:

  • display: none;: This hides elements with the class .hidden by setting their display property to "none." These elements will not be visible on the webpage.

9. #certificateContent:

  • margin-bottom: 20px;: This adds 20 pixels of margin at the bottom of the element with the ID certificateContent.

10. #downloadBtn:

  • margin-top: 10px;: This adds 10 pixels of margin at the top of the element with the ID downloadBtn.

This will give our Experience Certificate Generator an upgraded presentation. Create a CSS file with the name of styles.css and paste the given codes into your CSS file. Remember that you must create a file with the .css extension.

.container {
  max-width: 500px;
  margin: 0 auto;
  padding: 20px;

h1 {
  text-align: center;

form {
  margin-bottom: 20px;

label {
  display: block;
  margin-bottom: 5px;

input[type="text"] {
  width: 100%;
  padding: 8px;
  border: 1px solid #ccc;
  border-radius: 4px;
  margin-bottom: 10px;

button {
  background-color: #4CAF50;
  color: white;
  padding: 10px 20px;
  border: none;
  border-radius: 4px;
  cursor: pointer;

.certificate-preview {
  margin-top: 20px;
  border: 1px solid #ccc;
  padding: 20px;
  font-family: Arial, sans-serif;

.hidden {
  display: none;

#certificateContent {
  margin-bottom: 20px;

#downloadBtn {
  margin-top: 10px;

Step 3 (JavaScript Code):

Finally, we need to create a function in JavaScript. Let's break down the code step by step:

1. document.getElementById('certificateForm').addEventListener('submit', function(e) {...});

  • This line adds an event listener to the form element with the id attribute of 'certificateForm'. It listens for the 'submit' event of the form.
  • When the form is submitted, the provided function is executed with an event object e.
  • e.preventDefault(); prevents the default behavior of form submission, which would typically cause the page to reload.

2. The code then retrieves values from various form input fields (e.g., 'employeeName', 'companyName', 'duration', 'designation') and stores them in JavaScript variables.

3. It creates an HTML certificate content using template literals. The content includes the employee's name, designation, company name, and the duration of their work.

4. The certificate content is then inserted into an HTML element with the id attribute 'certificateContent'.

5. Two CSS classes, 'hidden', are removed from HTML elements with the id attributes 'certificateOutput' and 'downloadBtn'. This action makes these elements visible on the page.

  • 'certificateOutput' likely displays the generated certificate content.
  • 'downloadBtn' is a button that allows the user to download the certificate as a text file.

6. document.getElementById('downloadBtn').addEventListener('click', function() {...});

  • This part adds an event listener to the button with the id attribute 'downloadBtn'.
  • It listens for a 'click' event on the button.

7. When the 'downloadBtn' is clicked, the code retrieves the text content of the 'certificateContent' element.

8. It creates a Blob (Binary Large Object) containing the certificate text with the type 'text/plain'. A Blob is a data structure that can hold binary data, in this case, text data.

9. The code then creates a URL for the Blob using URL.createObjectURL(blob).

10. A new anchor (<a>) element is created.

11. The href attribute of the anchor is set to the generated URL, and the download attribute is set to 'experience_certificate.txt'.

12. Finally, the code programmatically clicks the anchor element, triggering the download of the certificate text file with the specified name.

Create a JavaScript file with the name script.js and paste the given codes into your JavaScript file and make sure it's linked properly to your HTML document so that the scripts are executed on the page. Remember, you’ve to create a file with .js extension.

document.getElementById('certificateForm').addEventListener('submit', function(e) {
  var employeeName = document.getElementById('employeeName').value;
  var companyName = document.getElementById('companyName').value;
  var duration = document.getElementById('duration').value;
  var designation = document.getElementById('designation').value;
  var certificateContent = `
    <p>This is to certify that <strong>${employeeName}</strong> has worked as a <strong>${designation}</strong> at <strong>${companyName}</strong> for a duration of <strong>${duration}</strong>.</p>
    <p>During their tenure, they have demonstrated excellent performance and contributed significantly to the success of our organization.</p>
    <p>We wish them all the best in their future endeavors.</p>
  document.getElementById('certificateContent').innerHTML = certificateContent;

document.getElementById('downloadBtn').addEventListener('click', function() {
  var certificateText = document.getElementById('certificateContent').textContent;
  var blob = new Blob([certificateText], { type: 'text/plain' });
  var url = URL.createObjectURL(blob);
  var link = document.createElement('a');
  link.href = url;
  link.download = 'experience_certificate.txt';

Final Output:

Experience Certificate Generator in HTML, CSS, and JavaScript.gif


Congratulations! You've successfully created an Experience Certificate Generator using HTML, CSS, and JavaScript. This tool can significantly streamline HR processes, making it easier to provide professional experience certificates to your employees.

Incorporate feedback and continuously improve your generator to meet the evolving needs of your organization.

Now, it's your turn to put this knowledge into practice and create your own certificate generator!

That’s a wrap!

I hope you enjoyed this post. Now, with these examples, you can create your own amazing page.

Did you like it? Let me know in the comments below 🔥 and you can support me by buying me a coffee.

And don’t forget to sign up to our email newsletter so you can get useful content like this sent right to your inbox!

Faraz 😊

End of the article

Subscribe to my Newsletter

Get the latest posts delivered right to your inbox

Related Post