Weather Forecasting Website
Weather Forecasting Website
1. Project Overview
The Weather Forecasting Web Application is a clean, modern web platform designed to provide real-time weather
updates for any city worldwide. It leverages OpenWeatherMap API to dynamically fetch and display important
weather data like temperature, description, humidity, and weather icons. The application demonstrates efficient
API handling, responsive front-end design, and asynchronous JavaScript programming.
2. Technologies Used
- HTML5 – For the structural layout
- CSS3 – For styling, animations, and responsiveness
- JavaScript (ES6+) – For dynamic API requests and DOM manipulation
- OpenWeatherMap API – To retrieve live weather data
3. Key Features
- Real-Time Weather Updates
- Modern, Responsive User Interface
- Dynamic Error Handling
- Responsive Design
- Weather Icons Integration
4. Project Structure
The project is composed of three primary files:
5. Source Code
5.1 index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Weather Forecast</title>
<style>
body {
text-align: center;
.container { background: rgba(255, 255, 255, 0.2); padding: 30px; border-radius: 15px; display: inline-block;
margin-top: 50px; box-shadow: 0px 4px 10px rgba(255, 255, 255, 0.5); animation: slideUp 1s ease-in-out;
backdrop-filter: blur(10px);}
@keyframes slideUp { from {transform: translateY(20px); opacity: 0;} to {transform: translateY(0); opacity: 1;}
}
input { padding: 12px; border-radius: 8px; border: none; width: 220px; font-size: 16px; transition: box-shadow
0.3s ease; }
input:focus { box-shadow: 0px 0px 8px rgba(255, 255, 255, 0.7); outline: none; }
button { padding: 12px 18px; background: linear-gradient(45deg, #ff7eb3, #ff758c); border: none; border-
radius: 8px; cursor: pointer; color: white; font-weight: bold; transition: transform 0.2s, background 0.3s; }
.weather-box { margin-top: 20px; padding: 20px; background: rgba(255, 255, 255, 0.3); border-radius: 15px;
display: inline-block; min-width: 270px; box-shadow: 0px 4px 10px rgba(255, 255, 255, 0.3); backdrop-filter:
blur(10px); animation: fadeIn 1.5s ease-in; }
.weather-box img { width: 150px; height: 150px; animation: bounce 1.5s infinite alternate; }
</style>
</head>
<body>
<div class="container">
<p>Get real-time weather updates for any city around the world.</p>
<div class="search-box">
</div>
</div>
<br><br>
<br><br>
<script src="script.js"></script>
</body>
</html>
5.2 style.css
body {
text-align: center;
padding: 20px;
color: white;
}
h1 {
font-size: 2.5em;
margin-bottom: 20px;
input {
padding: 10px;
font-size: 1em;
border: none;
border-radius: 5px;
margin-right: 10px;
button {
font-size: 1em;
background: #ff7eb3;
color: white;
border: none;
border-radius: 5px;
cursor: pointer;
button:hover {
background: #ff4f81;
#weather {
margin-top: 20px;
padding: 20px;
border-radius: 10px;
backdrop-filter: blur(10px);
display: inline-block;
min-width: 250px;
@keyframes fadeIn {
5.3 script.js
async function getWeather() {
if (!city) {
return;
const apiKey = 'c5053523815c00c91686efabacd46ead'; // Replace with your own valid API key
try {
document.getElementById('weather').innerHTML = `<p>${data.message}</p>`;
return;
document.getElementById('weather').innerHTML = `
<h2>${data.name}, ${data.sys.country}</h2>
<p>Temperature: ${data.main.temp}°C</p>
<p>Weather: ${data.weather[0].description}</p>
<p>Humidity: ${data.main.humidity}%</p>
`;
} catch (error) {
7. Important Note
Ensure you replace the sample API key with your own from OpenWeatherMap to guarantee stable access to live
data.