Pen Settings



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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

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


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


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.


                <!DOCTYPE html>
<html lang="en">
    <title>BMI Calculator</title>
    <!--Google Font-->
    <link rel="preconnect" href="">
    <link href=";700&display=swap" rel="stylesheet">
    <style media="screen">
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    height: 100vh;
    background: #046db9;
    background-color: #ffffff;
    padding: 30px 30px;
    width: 400px;
    position: absolute;
    transform: translate(-50%,-50%);
    top: 50%;
    left: 50%;
    border-radius: 5px;
    font-family: 'Poppins',sans-serif;
    box-shadow: 25px 25px 30px rgba(0,0,0,0.15);
.container h1{
	background: #024b94;
	color: white;
	text-align: center;
	font-size: 23px;
	letter-spacing: 1px;
	margin-top: -30px;
	margin-left: -30px;
	margin-right: -30px;
	margin-bottom: 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
.row span{
    font-weight: 500;
    width: 70%;
    height: 3.5px;
    -webkit-appearance: none;
    appearance: none;
    background-color: #dcdcdc;
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
    height: 15px;
    width: 15px;
    background-color: #1c1c1c;
    border-radius: 50%;
    cursor: pointer;
    font-size: 30px;
    font-weight: 700;
    letter-spacing: 1px;
    text-align: center;
    color: #0be881;
    font-size: 18px;
    text-align: center;
    letter-spacing: 1px;
box-shadow: 0 0 20px rgba(0,139,253,0.25);
margin-bottom: 60px;
    <div class="container">
			<h1>BMI Calculator</h1>
			<div class="display">
				        <p id="result">20.0</p>
				        <p id="category">Normal weight</p>
        <div class="row">
            <input type="range" min="20" max="200" value="20" id="weight" oninput="calculate()">
            <span id="weight-val">20 kg</span>
        <div class="row">
            <input type="range" min="100" max="250" value="100" id="height" oninput="calculate()">
            <span id="height-val">100 cm</span>


    <script type="text/javascript">
function calculate(){
  //Need to determine the constant of some id functions.
    var bmi;
    var result = document.getElementById("result");
  //The value of the height slider
    var height = parseInt(document.getElementById("height").value);
  //The value of the weight slider
    var weight = parseInt(document.getElementById("weight").value);
  //The value of height and width should be displayed in the webpage using "textContent".
    document.getElementById("weight-val").textContent = weight + " kg";
    document.getElementById("height-val").textContent = height + " cm";
//Now I have added the formula for calculating BMI in "bmi"
    bmi = (weight / Math.pow( (height/100), 2 )).toFixed(1);
  //With the help of "textContent" we have arranged to display in the result page of BMI
    result.textContent = bmi;

  //Now we have to make arrangements to show the text
  //When the BMI is less than 18.5, you can see the text below
    if(bmi < 18.5){
        category = "Underweight 😒"; = "#ffc44d";
  //If BMI is >=18.5 and <=24.9
    else if( bmi >= 18.5 && bmi <= 24.9 ){
        category = "Normal Weight 😍"; = "#0be881";
  //If BMI is >= 25 and <= 29.9 
    else if( bmi >= 25 && bmi <= 29.9 ){
        category = "Overweight 😮"; = "#ff884d";
  //If BMI is <= 30
        category = "Obese 😱"; = "#ff5e57";
  //All of the above text is stored in "category".

//Now you have to make arrangements to display the information in the webpage with the help of "textContent"
    document.getElementById("category").textContent = category;