<main>. JavaScript reads weather data from the API and writes it to specific DOM elements by ID.
DOM elements
The following elements are targeted byscript.js using document.getElementById.
| ID | Tag | Purpose |
|---|---|---|
#location | <span> | Displays city name from data.name |
#weather | <h6> | Displays weather description from data.weather[0].description |
#temp | <span> | Displays temperature in Celsius (converted from Kelvin) |
#icon | <img> | src set to the OpenWeatherMap icon URL |
#humidity | <p> | Displays humidity with the label Humidity: X% |
#wind | <p> | Displays wind speed with the label Wind Speed: X m/s |
CSS classes
.weather-card
The main card container. Uses a neumorphic dark style — a flat dark background with offset box shadows to create a raised appearance.
Key properties:
| Property | Value |
|---|---|
background | #343434 |
border-radius | 3rem |
width | 80vw |
max-width | 30rem |
box-shadow | 0.3rem 0.3rem 0.6rem #191b1b, -0.3rem -0.3rem 0.6rem #595959 |
padding | 2rem |
text-align | center |
.refresh
The circular refresh button centered below the weather data. Styled to match the neumorphic card aesthetic with a transparent background and rounded shape.
Key properties:
| Property | Value |
|---|---|
background | transparent |
border | none |
border-radius | 50% |
width | 27% |
height | 7rem |
font-size | 2rem |
color | #9c9c9d |
box-shadow | 0.6rem 0.2rem 0.6rem #252525, 0.3rem 0.3rem 1.2rem #4a4a4a |
inset, making the button appear pressed:
style.css
Refresh button HTML
The refresh button is defined inline inindex.html and reloads the page to trigger a new API fetch:
index.html
fa-refresh), loaded via CDN.