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 Solution to the error “Visual Studio Code can’t be opened because Apple cannot check it for malicious software” #2 How to add Read More Read Less Button using JavaScript? #3 How to check if radio button is checked or not using JavaScript? #4 Solution to “TypeError: ‘x’ is not iterable” in Angular 9 #5 PHP Login System using PDO Part 1: Create User Registration Page #6 How to uninstall Cocoapods from the Mac OS?

Recently Posted

#Apr 8 JSON.stringify() in JavaScript #Apr 7 Middleware in NextJS #Jan 17 4 advanced ways to search Colleague #Jan 16 Colleague UI Basics: The Search Area #Jan 16 Colleague UI Basics: The Context Area #Jan 16 Colleague UI Basics: Accessing the user interface
You might also like these
Learn to Establish Connection using MySQLi (object-oriented), MySQLi (procedural) and PDO with Example CodePHPAdd animation to your skills bar using CSSCSSJSON.stringify() in JavaScriptJavaScriptHow to disable scrolling on html body on menu click using JavaScript?JavaScriptHow to change style of all direct children of an element using jQuery?jQueryHow to add navigation menu in Angular 9 app?Angular