Yogesh Chauhan's Blog

Create a responsive pricing table using simple HTML and CSS

in CSS & HTML on August 7, 2019

We see everyday pricing tables on 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.

HTML

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.

CSS

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 add Read More Read Less Button using JavaScript? #4 How to uninstall Cocoapods from the Mac OS? #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to Use SQL MAX() Function with Dates?

Recently Posted

#Aug 15 Is PHP still good for back-end programming? #Aug 10 How to create a multisite network in WordPress? #Aug 3 How to create a circle that follows a cursor using JavaScript and CSS? #Aug 3 How to make a curtain slider using jQuery and CSS? #Aug 2 How to progressively load images and add a blurry placeholder? #Aug 1 How to create a placeholder loader (throbber) using CSS?
You might also like these
What are components in Angular?AngularA short basic guide on states in ReactReactKilling A Project Part 4: What Would Be Your Top 3 Priorities For Planning The Cancellation?MiscellaneousCreate a menu with a curtain falling animation using CSS and JavaScriptCSSHow to detect if browser supports WebP format on server side PHP script?PHPFull and Partial CUBE in Postgres with ExamplesPostgres