Create a responsive pricing table using simple HTML and CSS

August 7, 2019

We see everyday pricing tables on many different websites for e.g. basic pricing or free plan, advanced or pro or medium pricing and premium or business pricing. Generally those tables contain 3 columns pricing but some of them contain 2, 4 or even 5 columns pricing based on their user needs.

I am going to discuss about 3 columns pricing tables using CSS and you can easily make it to 2 to 5 pricing tables from that code. So, let’s start with the HTML as usual.

In the HTML code above, I have 3 columns and all of them are in 3 different containers element div with class=allColumns. I am going to set equal width in CSS for all of them.

Inside that container, I have added unordered list and added a class=singleColumn which will give different style to it. After that I have different list items but with unique classes so that each list items will have their own styles. At the end I’ve added Sign Up link as well but I haven’t specified any link in href for this example.

All of the code is same for all 3 columns except the background-color of header and buttons as I wanted to show users different colors for different plans.

I want the whole table to look like the image at the top of this page.

Let’s add CSS style to make the pricing table like the image above at the top.

In the CSS code above, there are some basic CSS properties I have used. I am keeping body color as red to match it with Todoist theme and Logo color. Now, as I have discussed in the HTML code above, I am keeping same width for all 3 columns which is styled in the class=allColumns. We need float left as we need the fist plan, which is basic to be shown left then gradually increases the plans. padding for space between those columns and as you can see width is 33.3% making it equal for all columns.

Next, I am styling single column class. Now this class we have assigned into a list elements so we need to get rid of those dots in unordered lists. For that we need list-style-type value set as none. Then there is a border which you can choose whether to add or not. The properties margin and padding will make it look really organised but you can choose not to use that as well. The next one is transition which I am using for hover event on those columns. I am setting box-shadow property on mouse hover event and adding a smooth transition to it. Again, it’s optional.

Next, I want other list items, their headers, buttons and links in different background-color and different styles as well. So, I have set up those different styles using different classes. It’s not mandatory.

Lastly, I have added media rule to set each columns width as 100% when the screen gets smaller fort e.g. any mobile device screens will less than 600px.


Most Read

#1 How to check if radio button is checked or not using JavaScript? #2 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #3 How to uninstall Cocoapods from the Mac OS? #4 How to Use SQL MAX() Function with Dates? #5 How to add Read More Read Less Button using JavaScript? #6 PHP Login System using PDO Part 1: Create User Registration Page

Recently Posted

Apr 7 Solution for “Yarn build: Failed because of a stylelint error” Apr 7 Make sure your links have descriptive text Apr 7 How to add Laravel to WordPress using Sage theme (and install Tailwind CSS)? Apr 2 How to create a sidebar using pure CSS? Apr 1 How to switch dark and light themes using pure CSS? Apr 1 How to calculate elapsed time in JavaScript?

You might also like these

The Differences Between HAVING Clause and WHERE Clause in SQLSQL/MySQLJavaScript: Methods for HTML DOM classList PropertyJavaScriptList of all Pseudo Elements in CSSCSSAll possible ways you can Insert Data in PostgresPostgresHow to create a sticky menu pin using CSS?CSSFor In Loop in Swift for BeginnersSwift