THE WORLD'S LARGEST WEB DEVELOPER SITE
×

HOW TO

HowTo Home

Menus

Icon Bar Menu Icon Accordion Tabs Vertical Tabs Tab Headers Top Navigation Responsive Topnav Side Navigation Fullscreen Navigation Off-Canvas Menu Hover Sidenav Buttons Horizontal Scroll Menu Vertical Menu Bottom Navigation Responsive Bottom Nav Fixed Menu Slide Down Bar on Scroll Sticky Navbar Hover Dropdowns Click Dropdowns Dropdown in Navbar Mega Menu Pagination Breadcrumbs Button Group Vertical Button Group

Images

Slideshow Modal Images Lightbox Responsive Image Grid Image Grid Image Overlay Image Effects Image Text Full Page Image Hero Image Rounded Images Meet the Team Flip an Image Shake an Image Portfolio Gallery Portfolio with Filtering

Buttons

Alert Buttons Animated Buttons Social Media Buttons Loading Buttons Next/prev Buttons Round Buttons Scroll To Top Button

Forms

Login Form Signup Form Contact Form Responsive Form Clear Input Field Copy Text to Clipboard Animated Search Custom Checkbox/Radio Toggle Switch Password Validation Toggle Password Visibility Multiple Step Form

Filters

Filter List Filter Table Filter Elements Sort List Sort Table

More

Modal Boxes Timeline Progress Bars Skill Bar Range Sliders Tooltips Popups Calendar Responsive Tables HTML Includes To Do List Loaders Star Rating User Rating Overlay Effect Contact Chips Cards Profile Card Alerts Notes Labels Circles Coupon Fixed Footer Equal Height Clearfix Snackbar Scroll Drawing Pricing Table Parallax Aspect Ratio Build a Web Site Toggle Like/Dislike Toggle Hide/Show Toggle Class Add Class Remove Class Arrows Shapes Vertical Line Animate Icons Countdown Timer Typewriter Coming Soon Page Center Website Thumbnails Chat Messages Testimonials Draggable HTML Element Syntax Highlighter JS Animations

Grid

2 Column Layout 3 Column Layout 4 Column Layout Mixed Column Layout

Google

Google Maps Google Translate Google Charts Google Fonts

Converters

Convert Weight Convert Temperature Convert Length Convert Speed

How TO - Temperature Converter


Learn how to create a temperature converter with HTML and JavaScript.


Temperature Converter

Type a value in any of the fields to convert between temperature measurements:


Create a Temperature Converter

Create an input element that can convert a value from one temperature measurement to another.

Step 1) Add HTML:

Example - Fahrenheit to Celcius

<p>
  <label>Fahrenheit</label>
  <input id="inputFahrenheit" type="number" placeholder="Fahrenheit"
  oninput="temperatureConverter(this.value)"
  onchange="temperatureConverter(this.value)">
</p>
<p>Celsius: <span id="outputCelsius"></span></p>

Step 2) Add JavaScript:

Example - Fahrenheit to Celcius

/* When the input field receives input, convert the value from fahrenheit to celsius */
function temperatureConverter(valNum) {
  valNum = parseFloat(valNum);
  document.getElementById("outputCelsius").innerHTML = (valNum-32) / 1.8;
}
Try it Yourself »


Convert from Fahrenheit to other Measurements

The table below shows how to convert from Fahrenheit to other temperature measurements:

Description Formula Example
Convert from Fahrenheit to Celsius ℃=(℉-32)/1.8 Try it
Convert from Fahrenheit to Kelvin K=((℉-32)/1.8)+273.15 Try it

Convert from Celsius to other Measurements

The table below shows how to convert from Celsius to other temperature measurements:

Description Formula Example
Convert from Celsius to Fahrenheit ℉=(℃*1.8)+32 Try it
Convert from Celsius to Kelvin K=℃+273.15 Try it

Convert from Kelvin to other Measurements

The table below shows how to convert from Kelvin to other temperature measurements:

Description Formula Example
Convert from Kelvin to Fahrenheit ℉=((K-273.15)*1.8)+32 Try it
Convert from Kelvin to Celsius ℃=K-273.15 Try it