Body Mass Index (BMI) is a numerical value derived from mass (weight) and height. It's a common and widely used screening tool to categorize a person's weight status – underweight, healthy weight, overweight, or obese. A high BMI can indicate excess body fat, which may increase your risk for certain chronic diseases.
How is BMI Calculated?
The formula for BMI is:
BMI = (Weight in Kilograms) / (Height in Meters)^2
Since the input for height is in centimeters, we first need to convert it to meters by dividing by 100. For example, 175 cm becomes 1.75 meters.
Using the calculator:
Enter your weight in kilograms (e.g., 70).
Enter your height in centimeters (e.g., 175).
Click "Calculate BMI".
BMI Categories
The World Health Organization (WHO) provides standard classifications for BMI values:
Underweight: Below 18.5
Healthy weight: 18.5 – 24.9
Overweight: 25 – 29.9
Obese: 30 and above
Important Considerations
While BMI is a useful tool, it's essential to remember:
BMI does not distinguish between fat mass and lean body mass. Athletes or very muscular individuals might have a high BMI without having excess body fat.
It doesn't account for body composition, fat distribution, or individual metabolic differences.
BMI should be used as a screening tool, not a diagnostic tool. Consult a healthcare professional for a comprehensive assessment of your health and weight status.
function calculateBMI() {
var weightInput = document.getElementById("weight");
var heightInput = document.getElementById("height");
var resultDiv = document.getElementById("result");
var weight = parseFloat(weightInput.value);
var heightCm = parseFloat(heightInput.value);
if (isNaN(weight) || isNaN(heightCm) || weight <= 0 || heightCm <= 0) {
resultDiv.innerHTML = "Please enter valid numbers for weight and height.";
resultDiv.style.color = "#dc3545"; /* Red for error */
return;
}
var heightM = heightCm / 100; // Convert height from cm to meters
var bmi = weight / (heightM * heightM);
// Round BMI to one decimal place
var formattedBMI = bmi.toFixed(1);
var bmiCategory = "";
var resultTextColor = "#28a745"; // Default to success green
if (formattedBMI = 18.5 && formattedBMI = 25 && formattedBMI <= 29.9) {
bmiCategory = "Overweight";
resultTextColor = "#fd7e14"; /* Orange */
} else {
bmiCategory = "Obese";
resultTextColor = "#dc3545"; /* Red */
}
resultDiv.innerHTML = "Your BMI: " + formattedBMI + " (" + bmiCategory + ")";
resultDiv.style.color = "#004a99"; /* Main blue for BMI value */
resultDiv.querySelector("span").style.color = resultTextColor; /* Color category text */
}