SHARE
Facebook X Pinterest WhatsApp

Create a 2020 Calendar Using CSS

thumbnail Create a 2020 Calendar Using CSS
Apr 27, 2020

In this article, I will show you the easy process of building a calendar with Cascading Style Sheets (CSS). Calendars can be quite important on a website for displaying and storing data. Users might be more willing to view an interactive and well-styled calendar rather than a long list of events. CSS is very helpful in building just such a calendar, plus, JavaScript libraries can help make it interactive. JavaScript libraries can help you change views quickly and easily, as well as add animation.

In the example below, we will focus on creating a calendar using HTML and CSS. So, let’s get to work.

Here is the example:

<!DOCTYPE html>
<html>
<head>
<style>
* {box-sizing: border-box;}
ul {list-style-type: none;}
body {font-family: Calibri light, Arial, Helvetica}
.month {
  padding: 50px 75px;
  width: 100%;
  background: #C71585;
  text-align: center;
}
.month ul {
  margin: 0;
  padding: 0;
}
.month ul li {
  color: white;
  font-size: 40px;
  text-transform: uppercase;
  letter-spacing: 6px;
}
.month .prev {
  float: left;
  padding-top: 20px;
}
.month .next {
  float: right;
  padding-top: 20px;
}
.weekdays {
  margin: 0;
  padding: 10px 0;
  background-color: #778899;
}
.weekdays li {
  display: inline-block;
  width: 13.8%;
  color: grey light;
  text-align: center;
}
.days {
  padding: 15px 0;
  background: #D3D3D3;
  margin: 0;
}
.days li {
  list-style-type: none;
  display: inline-block;
  width: 13.8%;
  text-align: center;
  margin-bottom: 5px;
  font-size:12px;
  color: #778899;
}
.days li .active {
  padding: 7px;
  background: #C71585;
  color: white;
}
@media screen and (max-width:720px) {
  .weekdays li, .days li {width: 15.1%;}
}
@media screen and (max-width: 440px) {
  .weekdays li, .days li {width: 15.5%;}
  .days li .active {padding: 4px;}
}
@media screen and (max-width: 390px) {
  .weekdays li, .days li {width: 12.2%;}
}
</style>
</head>
<body>
<h1>CSS Calendar Example</h1>
<div class="month">      
  <ul>
    <li class="prev"></li>
    <li class="next"></li>
    <li>
      March<br>
      <span style="font-size:28px">2020</span>
    </li>
  </ul>
</div>
<ul class="weekdays">
  <li>Mo</li>
  <li>Tu</li>
  <li>We</li>
  <li>Th</li>
  <li>Fr</li>
  <li>Sa</li>
  <li>Su</li>
</ul>
<ul class="days">  
  <li>1</li>
  <li>2</li>
  <li>3</li>
  <li>4</li>
  <li>5</li>
  <li>6</li>
  <li>7</li>
  <li>8</li>
  <li>9</li>
  <li>10</li>
  <li>11</li>
  <li>12</li>
  <li>13</li>
  <li>14</li>
  <li>15</li>
  <li>16</li>
  <li>17</li>
  <li>18</li>
  <li>19</li>
  <li>20</li>
  <li>21</li>
  <li>22</li>
  <li>23</li>
  <li><span class="active">24</span></li>
  <li>25</li>
  <li>26</li>
  <li>27</li>
  <li>28</li>
  <li>29</li>
  <li>30</li>
  <li>31</li>
</ul>
</body>
</html>

image name here

Conclusion

Even though calendars can be easily created and stylized in HTML and CSS, as shown in the example above, if you want to make them interactive, you will need to know JavaScript. Calendars are very useful to have on your site. Many users are pleased when they see a well-crafted and stylized calendar. I hope the article helped you to easily understand how to create a calendar from scratch.

Recommended for you...

Importing Custom Less Styles at Run-time in Angular
Rob Gravelle
Jun 14, 2022
Setting CSS Values from Less Variables in Angular
Rob Gravelle
Jun 4, 2022
Color Manipulation with JavaScript
Rob Gravelle
May 21, 2022
An Introduction to CSS-in-JS
Rob Gravelle
May 14, 2022
HTML Goodies Logo

The original home of HTML tutorials. HTMLGoodies is a website dedicated to publishing tutorials that cover every aspect of being a web developer. We cover programming and web development tutorials on languages and technologies such as HTML, JavaScript, and CSS. In addition, our articles cover web frameworks like Angular and React.JS, as well as popular Content Management Systems (CMS) that include WordPress, Drupal, and Joomla. Website development platforms like Shopify, Squarespace, and Wix are also featured. Topics related to solid web design and Internet Marketing also find a home on HTMLGoodies, as we discuss UX/UI Design, Search Engine Optimization (SEO), and web dev best practices.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.