HTML and CSS

Calendar design

Monday

9

June 2025

spring

What does this CSS code do?

This CSS styles a compact, stylized calendar component, giving it a card-like appearance with a modern and clean aesthetic. Here’s a breakdown of how each section contributes to the overall design:

.calendar-container

  • Purpose: Centers the entire calendar and limits its width.
  • Key Styles:
    • margin: 0 auto; → Horizontally centers the calendar.
    • max-width: 260px; → Makes the calendar compact.
    • font-family: "Oswald", sans-serif; → Uses a modern sans-serif font for a clean look.

.calendar-header

  • Purpose: Decorative top bar of the calendar, like a stylized "binding" or visual top section.
  • Key Styles:
    • display: flex; and justify-content: space-around; → Evenly spaces its child elements horizontally.
    • background-color: #cc5446; → Red background gives it a bold, eye-catching look.
    • border-top-right-radius and border-top-left-radius: 10px; → Rounded top corners.
    • border-bottom: 4px solid #ffffff; → Creates a "cut-off" look separating the header from the body.

.calendar-header span

  • Purpose: Acts as decorative tabs or binding rings, mimicking spiral-bound or clipped calendar styles.
  • Key Styles:
    • background-color: #edf0f1; → Light gray background matches the calendar body.
    • border: 4px solid #ffffff; → Thick white border for contrast.
    • width: 20px;, height: 40px; → Small tab-like elements.
    • border-radius: 6px; → Rounded for a soft appearance.
    • position: relative; top: -20px; → Pulls the tabs upward so they appear attached to the top of the calendar (above the red header).

.calendar-body

  • Purpose: The main content area showing the date info.
  • Key Styles:
    • background-color: #edf0f1; → Soft, neutral background.
    • min-height: 100px; → Ensures some vertical space.
    • border-bottom-right-radius and border-bottom-left-radius: 10px; → Rounded bottom to match the header.
    • padding: 20px; and text-align: center; → Creates space and centers content.

Headings inside .calendar-body

These headings represent different parts of the date (e.g., day of the week, date number, and month).

1. h1

  • Small, uppercase (e.g., "Monday")
  • font-size: 0.80em; → Very subtle emphasis.

2. h2

  • Large number (e.g., "9")
  • font-size: 4em; → Stands out prominently.

3. h3

  • Medium emphasis (e.g., "June 2025")
  • Lighter font weight for less emphasis than the date number.
CSS
@import url('https://fonts.googleapis.com/css2?family=Oswald:wght@500&display=swap');

.calendar-container {
  margin: 0 auto;
  max-width: 260px;
  font-family: "Oswald", sans-serif;
} 

.calendar-header {
  display: flex;
  flex-direction: row;
  justify-content: space-around;
  background-color: #cc5446;
  border-top-right-radius: 10px;
  border-top-left-radius: 10px;
  border-bottom: 4px solid #ffffff;
}

.calendar-header span {
  background-color: #edf0f1;
  border: 4px solid #ffffff;
  width: 20px;
  height: 40px;
  border-radius: 6px;
  position: relative;
  top: -20px;
}

.calendar-body {
  background-color: #edf0f1;
  min-height: 100px;
  border-bottom-right-radius: 10px;
  border-bottom-left-radius: 10px;
  padding: 20px;
  text-align: center;
}

.calendar-body h1 {
  font-size: .80em;
  margin: 0;
  text-transform: uppercase;
}

.calendar-body h2 {
  font-size: 4em;
  margin: 0;
  text-transform: uppercase;
}

.calendar-body h3 {
  font-size: 1.2em;
  font-weight: normal;
}
HTML
<div class="calendar-container"> 
<div class="calendar-header">

 <span></span> 
 <span></span>
 
</div>
 
<div class="calendar-body">
  <h1>Monday</h1> 
  <h2>09</h2> 
  <h3>June 2025</h3> 
  <h4>spring</h4>   
</div> 

</div>