Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html lang="en">
<head>
  <meta charset="utf-8">

  <title>Temperature Converter</title>
  <meta name="description" content="The HTML5 Herald">
  <meta name="author" content="SitePoint">

  <link rel="stylesheet" href="css/styles.css?v=1.0">
<link href="https://fonts.googleapis.com/css2?family=Raleway:wght@700;900&display=swap" rel="stylesheet">
  <script src="jquery.min.js"></script>
</head>

<body>
  <div class='container'>
    <h1>Temperature Convertenator</h1>
    <div class='desc'>Gonna be getting all calculate-y up in here!</div>
    <div class='msg'>How is it outside?: <span Id='msg'> </span></div>
    
   
  
<div class='inputs'>
<input id="degree" type="number">
    <select id="labels">
  <option value="kelvin" >Kelvin</option>
  <option value="celsius">Celsius</option>
  <option value="fehrenheit">Fehrenheit</option>
  <option value="newton">Newton</option>
</select><br>
 <button class='button' type="button" onclick="calculate()">Submit</button>
</input>

  </div>
    <div id='results'>
  <div id='result'>Kelvin: <span id='ktemp'></span></div>
   <div id='result'> Celsius: <span id='ctemp'></span></div>
  <div id='result'> Fahrenheit: <span Id='ftemp'></span></div>
      <div id='result'>Newton: <span id='ntemp'></span></div>
      
  </div>
    
    
    
  </div>
</body>
</html>
              
            
!

CSS

              
                body
{
  font-size:25px;
  font-family: 'Raleway', sans-serif;
}
.container
{
  text-align:center;
  display:flex;
  flex-direction:column;
  align-items:center;
  padding: 15px;
}
.desc{
  font-weight:700;
  padding:20px;
}
h1{
  font-size:45px;
    font-weight:900;
   background: -webkit-linear-gradient(#800000, #0000A0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}
.inputs{
  padding:15px;
  margin:15px;
}
.button{
    -webkit-appearance: none;
   -moz-appearance: none;
   appearance: none;  
  font-weight:900;
  font-size: 34px;
  padding:10px;
  margin:10px;
  text-decoration:none;
  border: 2px solid #0000A0;
}
.msg{
  border: 3px solid #0000A0;
  padding:25px;
  margin:55px;
  
}
#result{
  padding:30px;
  margin:15px;
  border-radius:50%;
  width: 200px;
background-color:blue;
  color:white;
}
#results{
  display:flex;
  flex-direction:row;
}
.hot {
    border:3px solid red;
    background-color:#800000;
}
.cold {
    border:3px solid dodgerblue;
  background-color:#0000A0;
}

select {
   -webkit-appearance: none;
   -moz-appearance: none;
   appearance: none;     
  font-size: 32px;
  border-radius:10px;
  padding:5px;
   border: 2px solid red;
}
input {
  font-size: 32px;
  border-radius:10px;
  border: 2px solid #0000A0;
  padding:5px;
}
              
            
!

JS

              
                
function calculate(){
 
var temp =  document.getElementById("degree").value;
var type= document.getElementById("labels").value;

  

if (type == 'fehrenheit')
    {
      let fahrenheit = Math.floor(temp);
      let celsius = Math.floor((temp - 32) * .5556);
      let kelvin = celsius + 273;

      /* Newton from Celsius */
      let newton = celsius * (33/100);

      /*Rounding off the Newton */
      newton = Math.floor(newton);
      
             if (fahrenheit >= 150)
  {
document.getElementById("msg").innerHTML ='The world burns.';
  document.getElementById('msg').style.color = 'red';

  }
 else if (fahrenheit >= 60 && fahrenheit <= 149)
  {
document.getElementById("msg").innerHTML ='Pretty Warm Out';
    document.getElementById('msg').style.color = 'orange';
  }
  else if (fahrenheit <= 60 && fahrenheit > 30)
  {
document.getElementById("msg").innerHTML ='Bit Nippy';
    document.getElementById('msg').style.color = 'dodgerblue';

  }
   else if (fahrenheit >= -10 && fahrenheit <= 30)
     {
       document.getElementById("msg").innerHTML ='You will freeze';
       document.getElementById('msg').style.color = 'darkblue';
     }
  else {
   document.getElementById("msg").innerHTML ='Ice age'; 
  document.getElementById('msg').style.color = '#203354';
  }
      
      
      
      
      document.getElementById('ktemp').innerHTML = kelvin;
        document.getElementById('ctemp').innerHTML = celsius;
        document.getElementById('ntemp').innerHTML = newton;
        document.getElementById('ftemp').innerHTML = fahrenheit;
    }
  

  
 if (type == 'celsius')
    {
     let celsius = Math.floor(temp);
        /* Newton from Celsius */
    let newton = celsius * (33/100);

    /*Rounding off the Newton */
    newton = Math.floor(newton);
      
    /*Celsius is Kelvin minus 273*/
     let kelvin = celsius+273;
      
      /*Changing Celsius to Fahrenheit */
let fahrenheit = celsius * (9/5) + 32;
      
      

/* Rounding off the Fahrenheit */
fahrenheit = Math.floor(fahrenheit);
      
             if (fahrenheit >= 150)
  {
document.getElementById("msg").innerHTML ='The world burns.';
  document.getElementById('msg').style.color = 'red';

  }
 else if (fahrenheit >= 60 && fahrenheit <= 149)
  {
document.getElementById("msg").innerHTML ='Pretty Warm Out';
    document.getElementById('msg').style.color = 'orange';
  }
  else if (fahrenheit <= 60 && fahrenheit > 30)
  {
document.getElementById("msg").innerHTML ='Bit Nippy';
    document.getElementById('msg').style.color = 'dodgerblue';

  }
   else if (fahrenheit >= -10 && fahrenheit <= 30)
     {
       document.getElementById("msg").innerHTML ='You will freeze';
       document.getElementById('msg').style.color = 'darkblue';
     }
  else {
   document.getElementById("msg").innerHTML ='Ice age'; 
  document.getElementById('msg').style.color = '#203354';
  }
      
      
      
       document.getElementById('ktemp').innerHTML = kelvin;
      document.getElementById('ctemp').innerHTML = celsius;
      document.getElementById('ntemp').innerHTML = newton;
      document.getElementById('ftemp').innerHTML = fahrenheit;
    }
  
  
  
 if (type == 'kelvin')
    {
      
    let kelvin = Math.floor(temp);
  
    /*Celsius is Kelvin minus 273*/
     let celsius = kelvin-273;

    /* Newton from Celsius */
    let newton = celsius * (33/100);

    /*Rounding off the Newton */
    newton = Math.floor(newton);

    /*Rounding off the Celsius */
    celsius = Math.floor(celsius);
      /*Changing Celsius to Fahrenheit */
    let fahrenheit = Math.floor(celsius * (9/5) + 32);

      
             if (fahrenheit >= 150)
  {
document.getElementById("msg").innerHTML ='The world burns.';
  document.getElementById('msg').style.color = 'red';

  }
 else if (fahrenheit >= 60 && fahrenheit <= 149)
  {
document.getElementById("msg").innerHTML ='Pretty Warm Out';
    document.getElementById('msg').style.color = 'orange';
  }
  else if (fahrenheit <= 60 && fahrenheit > 30)
  {
document.getElementById("msg").innerHTML ='Bit Nippy';
    document.getElementById('msg').style.color = 'dodgerblue';

  }
   else if (fahrenheit >= -10 && fahrenheit <= 30)
     {
       document.getElementById("msg").innerHTML ='You will freeze';
       document.getElementById('msg').style.color = 'darkblue';
     }
  else {
   document.getElementById("msg").innerHTML ='Ice age'; 
  document.getElementById('msg').style.color = '#203354';
  }
      
      
      
    document.getElementById('ktemp').innerHTML = kelvin;
    document.getElementById('ctemp').innerHTML = celsius;
    document.getElementById('ntemp').innerHTML = newton;
    document.getElementById('ftemp').innerHTML = fahrenheit;
   
    
    }
  

  
    if (type == 'newton')
    {
      let newton = Math.floor(temp);
      let celsius = Math.floor( newton *  100 / 33);
      /*Changing Celsius to Fahrenheit */
let fahrenheit= celsius * (9/5) + 32;

/* Rounding off the Fahrenheit */
fahrenheit = Math.floor(fahrenheit);
       let kelvin = celsius+273;
      
      document.getElementById('ktemp').innerHTML = kelvin;
    document.getElementById('ctemp').innerHTML = celsius;
    document.getElementById('ntemp').innerHTML = newton;
    document.getElementById('ftemp').innerHTML = fahrenheit;
  
      
       if (fahrenheit >= 150)
  {
document.getElementById("msg").innerHTML ='The world burns.';
  document.getElementById('msg').style.color = 'red';

  }
 else if (fahrenheit >= 60 && fahrenheit <= 149)
  {
document.getElementById("msg").innerHTML ='Pretty Warm Out';
    document.getElementById('msg').style.color = 'orange';
  }
  else if (fahrenheit <= 60 && fahrenheit > 30)
  {
document.getElementById("msg").innerHTML ='Bit Nippy';
    document.getElementById('msg').style.color = 'dodgerblue';

  }
   else if (fahrenheit >= -10 && fahrenheit <= 30)
     {
       document.getElementById("msg").innerHTML ='You will freeze';
       document.getElementById('msg').style.color = 'darkblue';
     }
  else {
   document.getElementById("msg").innerHTML ='Ice age'; 
  document.getElementById('msg').style.color = '#203354';
  }
  
    
    }
  



}
              
            
!
999px

Console