A beginner-friendly web-based calculator built with HTML, CSS, and JavaScript. It supports basic arithmetic operations — addition, subtraction, multiplication, and division — with a clean, responsive interface.
- ➕ Addition - Add two numbers together
- ➖ Subtraction - Subtract the second number from the first
- ✖️ Multiplication - Multiply two numbers
- ➗ Division - Divide the first number by the second
- 🎨 Clean Interface - Simple, user-friendly design with bisque background
- 📱 Responsive Design - Works on desktop and mobile devices
- ⚡ Instant Results - Real-time calculation display
- Enter Numbers: Input two numbers in the provided text fields
- Choose Operation: Click one of the four operation buttons (+, -, *, /)
- View Result: The result will appear instantly below the buttons
- Enter
10in the first field and5in the second field - Click the
+button to get15 - Click the
-button to get5 - Click the
*button to get50 - Click the
/button to get2
simple-calculator/
├── index.html # Main HTML structure
├── css/
│ └── style.css # Styling and layout
├── images/
│ └── demo.png # screenshot of project demo
├── js/
│ └── main.js # JavaScript calculation logic
└── README.md # This documentation
- Download or clone the project files
- Open
index.htmlin any modern web browser - Start calculating immediately - no additional setup required!
- Two input fields for number entry
- Four operation buttons with unique IDs
- Result display area using
<h2>element - Semantic form structure for better accessibility
- Flexbox Layout: Centered, responsive design
- Color Scheme: Bisque background with azure input fields
- Typography: Large, readable fonts (60px heading, 20px inputs)
- Interactive Elements: Rounded corners and consistent spacing
- Responsive Design: Adapts to different screen sizes
- Event Listeners: Each button has its own click handler
- DOM Manipulation: Direct element selection and value updates
- Type Conversion: Automatic string-to-number conversion
- Modular Functions: Separate function for each operation
- Console Logging: Results logged for debugging purposes
document.querySelector('#addition').addEventListener('click', add)
document.querySelector('#sub').addEventListener('click', sub)
document.querySelector('#mult').addEventListener('click', mult)
document.querySelector('#div').addEventListener('click', div)Each operation follows the same pattern:
- Get values from both input fields
- Convert strings to numbers
- Perform the calculation
- Display result in the DOM
- Log result to console
Works in all modern browsers:
- ✅ Chrome
- ✅ Firefox
- ✅ Safari
- ✅ Edge
- ✅ Opera
- No input validation (accepts any text)
- Division by zero returns
Infinity - No decimal precision control
- No keyboard support
- No operation history
Potential improvements could include:
- Input validation and error handling
- Keyboard shortcuts for operations
- Decimal precision control
- Calculation history feature
- Memory functions (M+, M-, MR, MC)
- Scientific operations (square root, power, etc.)
- Clear/Reset functionality
- Keyboard accessibility improvements
This is a beginner-friendly project perfect for learning web development fundamentals. Feel free to:
- Fork the repository
- Add new features
- Fix bugs or improve code
- Submit pull requests
This project is open source and available under the MIT License.
This project demonstrates:
- Basic HTML form structure
- CSS Flexbox layout
- JavaScript DOM manipulation
- Event handling
- Function organization
- Responsive web design principles
Perfect for beginners learning web development fundamentals!
