This page generates a monthly calendar as semantic HTML. The calendar uses a real table with a <caption>, column headings, and CSS for presentation instead of obsolete attributes such as bgcolor, align, border, or <font>.
Use the previous and next controls below to change the displayed month, then copy the generated code. For a data-driven calendar with events, see the PHP calendar tutorial.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
A calendar is naturally tabular data: weekdays form the columns and dates occupy the cells. Use <caption> for the month and year, <thead> for weekday headings, <tbody> for dates, and scope="col" on weekday headings.
<table class="calendar">
<caption>September 2026</caption>
<thead><tr>
<th scope="col">Sun</th>
<!-- Continue through Saturday -->
</tr></thead>
<tbody>
<tr><td><time datetime="2026-09-01">1</time></td></tr>
</tbody>
</table>
The first version includes month navigation links generated by this PHP page. If the destination page does not run PHP, use the static version farther below.
Use this version when you only need a fixed month and do not want the previous/next links.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
For a narrower layout, change the CSS rather than adding old HTML width attributes. This compact version reduces the maximum width, cell padding, and cell height.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
Modern HTML keeps structure in the markup and presentation in CSS. Avoid old attributes such as bgcolor, align, cellspacing, cellpadding, and the obsolete <font> element.
.calendar {
border-collapse: collapse;
width: min(100%, 34rem);
text-align: center;
}
.calendar th, .calendar td {
border: 1px solid #bbb;
padding: 0.5rem;
}
A calendar grid should expose its structure rather than relying only on visual alignment. A caption identifies the month, column headers identify weekdays, and real table markup preserves row/column relationships for assistive technology.
<th scope="col">.This generator creates the month grid on the server. For calendars populated from PHP or a database, continue with the PHP calendar tutorial. To build a printable schedule with dated plans, see the monthly planner.
The month navigation values on this page are validated as integers before they are used. When building your own generator, validate query-string values rather than trusting raw $_GET input.
Use CSS for borders, spacing, colors, sizing, and alignment instead of border, bgcolor, align, cellpadding, or cellspacing.
A calendar has genuine row-and-column relationships, so a table is more appropriate than manually spacing text.
Use header cells with scope="col" so the weekday relationship is explicit.
Query-string values are user input. Validate them server-side before using them in date calculations or application logic.
Use a table for the calendar grid, a caption for the month and year, column header cells for weekdays, and regular cells for dates.
No. Those are presentational techniques from older HTML. Use CSS for borders, colors, spacing and sizing.
It identifies each weekday heading as the header for its calendar column, which makes the table structure clearer to assistive technology.
Yes. Use the static generated version, which contains the HTML and CSS for the selected month without PHP-powered navigation links.
Adjust CSS such as max-width, padding and font-size. Do not use obsolete HTML width or font attributes for presentation.
For dynamic events, generate the date cells from application data. The related PHP calendar and monthly planner tutorials show server-side approaches.
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.
| endawoke | 08-11-2013 |
| the code has only upto 2014 so it is dificalt to know other holy dayes | |
| bob | 26-11-2014 |
| ok but highlight the date | |
| Ryan | 16-01-2015 |
| Ok Thanks... | |
| Lungelo | 22-07-2015 |
| I need a code of a calendar that is more or less like outlook calendar, that will allow me to easily make appointment and print them | |
| David | 01-02-2016 |
| Please, I need step by step lecture on how to html calendar, for daily devotion that displays each day with date and topic. Thanks | |
| smo1234 | 04-02-2016 |
| For that you need Activity calendar, that can be developed using database support where the data is stored. You can see one event calendar example here. | |
| Portia | 09-09-2016 |
| Hey I need a July 2016 calender an its code please | |
| smo1234 | 10-09-2016 |
| There is one in PHP section showing 2016 calendar. | |
| Gerald | 18-12-2018 |
| How to change the date, for examlpe jan.1 2018 because i don't know how to change it. | |