How I Built a Simple Dreisatz Calculator with HTML, CSS and JavaScript
I wanted to build a small browser-based calculator that could make the German Dreisatz method easier to understand and use.
The project uses only HTML, CSS and JavaScript, so there are no external libraries or frameworks required.
What is Dreisatz?
Dreisatz is a common mathematical method for solving proportional relationships.
For example:
If 500 g of mushrooms cost €3.85, how much would 200 g cost?
The calculation is:
500 g → €3.85
200 g → x
x = (3.85 × 200) / 500
x = €1.54
Building the calculator
The calculator has three input fields:
- Original quantity
- Original value
- New quantity
JavaScript then calculates the unknown value using:
const result = (b * c) / a;
The result can then be displayed directly in the browser.
Why I used vanilla JavaScript
For a small calculator like this, a framework is not necessary.
Vanilla JavaScript keeps the project lightweight and makes the basic calculation logic easy to understand. It also means that the calculator can run without loading additional libraries.
Example
A simple example could be:
500 g = €3.85
200 g = ?
Result = €1.54
The calculator can also format the result using the German number format.
Project
I created a more complete online version of the calculator here:
Dreisatz Rechner: https://dreisatzberechner.com/
The goal is to make proportional calculations simple and accessible directly in the browser.
What I learned
Building a small calculator is a useful way to practice the fundamentals of web development.
The project helped me work with:
- HTML form elements
- CSS layout and styling
- JavaScript calculations
- DOM manipulation
- Number formatting
- Basic user input validation
Small projects like this are a good way to practice web development because the final result is immediately usable.
Top comments (0)