You are currently viewing Temperature Convertor using HTML, CSS & JavaScript

Temperature Convertor using HTML, CSS & JavaScript

Temperature Convertor using HTML, CSS & JavaScript

Hello everyone. Welcome to today’s tutorial on Codewithrandom. We’ll learn how to make a Temperature Convertor that will convert the temperature of the location in Celsius to Fahrenheit and vice versa. In Today’s session, We will use HTML, CSS, and JavaScript to complete this Project.

The HTML (Hypertext Markup Language) will help us to create the structure for the list with some necessary attributes and elements to make Temperature Converter.

Then we will use CSS (Cascading Stylesheet) which will help us to style or design the project with suitable padding and alignment in the Temperature Converter project.

At last, we will use JS (JavaScript) which will add logic to make the Temperature Converter project responsive from the user end.

I hope you have got an idea about the project.

HTML Code for Convertor

<html lang="en">
    <title>Temperature Conversion</title>
    <!--Google font-->
    <link rel="preconnect" href="">
    <link href="" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
    <div class="wrapper">
        <div class="container">
            <label for="celsius">Celsius</label>
            <input type="number" id="celsius" oninput= "celToFar()">
        <div class="container">
            <label for="fahrenheit">Fahrenheit</label>
            <input type="number" id="fahrenheit" oninput = "farToCel()">
    <script src="script.js"></script>

First we’ll start with creating the structure of the Temperature Converter project for that as you can see the above code we have used all the necessary elements & attributes. Let us know code the CSS part to add styling and aligned the tags.

Ecommerce Website Using Html Css And Javascript Source Code

CSS Code for Convertor

    padding: 0;
    margin: 0;
    box-sizing: border-box;
    font-family: "Roboto Mono", monospace;
    font-size: 18px;
    background-color: red;
    width: 450px;
    background-color: #ffffff;
    padding: 70px 40px;
    position: absolute;
    transform: translate(-50%,-50%);
    left: 50%;
    top: 50%;
    box-shadow: 0 20px 25px rgba(0,0,0,0.25);
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    width: 45%;
    width: 100%;
    height: 50px;
    border-radius: 5px;
    border: 2px solid #d2d2d2;
    outline: none;
    margin-top: 8px;
    padding: 0 10px;
    border-color: #3164ff;

Second comes the CSS code in which we have styled for the structure we have padded as well as aligned the Temperature Converter project so that it is properly situated and doesn’t get messy with suitable CSS elements. Lets code the JavaScript part to make responsive.

Portfolio Website using HTML and CSS (Source Code)

JavaScript Code for Convertor

let celsius = document.getElementById("celsius");
let fahrenheit = document.getElementById("fahrenheit");

function celToFar(){
    let output = ( parseFloat(celsius.value) * 9/5 ) + 32;
    fahrenheit.value = parseFloat(output.toFixed(2));

function farToCel(){
    let output = ( parseFloat(fahrenheit.value) - 32) * 5/9;
    celsius.value = parseFloat( output.toFixed(2));

Last stage of the project the JavaScript in which we have added the logical and coded as per the requirement with some conditions. Let us see the Final Output of the project Temperature Convertor using HTML, CSS & JavaScript (Source Code) | Temperature Converter.

Final Output Temperature Convertor using HTML, CSS & JavaScript

See the Pen
Temperature Convertor
by Harsh Sawant (@harshh9)
on CodePen.

We have successfully created our Temperature Convertor using HTML, CSS & JavaScript (Source Code) | Temperature Converter. You can use this project for your personal needs and the respective lines of code are given with the code pen link mentioned above.

50+ Html ,Css & Javascript Projects With Source Code

If you find out this Blog helpful, then make sure to search code with random on google for Front End Projects with Source codes and make sure to Follow the Code with Random Instagram page.

Code Idea – codingartist

Written By – Harsh Sawant

Code By – @harshh9

Leave a Reply