DEV Community

Devendra Kumar Dixit
Devendra Kumar Dixit

Posted on

How I Built a Simple BMI Calculator with HTML, CSS, and JavaScript

Introduction

When learning JavaScript, one of the best ways to improve is by building small, practical tools.

In this article, I'll show how I built a simple BMI calculator using HTML, CSS, and vanilla JavaScript.

This project is beginner-friendly and helps you practice working with form inputs and JavaScript logic.

What We'll Build

List the features.

Features:

• Instant BMI calculation

• Clean and simple interface

• Works on mobile devices

• Built using only HTML, CSS, and JavaScript

Live Demo

Demo Link
(https://yuvronixstudio.github.io/simple-bmi-calculator/)

Project Structure

project-folder
├── index.html
├── style.css
└── script.js

HTML Code:

The HTML structure contains two input fields:

• Height
• Weight

The result will be displayed as the user fills in the input fields.

CSS Styling:

The layout uses flexbox to center the calculator on the page.

JavaScript Logic:

The BMI formula:

BMI = weight / (height x height)

Result Output:


Source Code:

Source Code:
(https://github.com/YuvronixStudio/simple-bmi-calculator/)

If you'd like the full source code bundle
for all my JavaScript calculators (BMI, EMI, Interest),
you can find it here:

(https://yuvronixstudio.gumroad.com/)

Top comments (0)