Create a Responsive Pricing Table Using HTML & CSS


  • How to structure a basic HTML layout for a pricing table.
  • Step-by-step guide to styling the table using CSS.
  • Responsive design techniques to make the table look great on all devices.
  • Why these design choices are important, both for user experience and for showing your HTML & CSS skills in interviews.

Desktop and Mobile view

pricing table Desktop view
pricing table Mobile view


Basic HTML Structure of the Pricing Table

  • The HTML structure should be semantic and easy to understand. Using <div> tags for containers, <ul> for lists, and <h3> for titles ensures that your content is well-organized and readable.
  • This basic layout provides a strong foundation for styling with CSS later on.
  • pricing-container, pricing-card, featured, pricing-title, price , and btn are classnames . we have used those classnames to group style.

Styling with CSS – Step-by-Step Guide

/* Reset some default styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

/* Body Styling */
body {
  font-family: Arial, sans-serif;
  background-color: #f4f7fa;
  padding: 20px;
}
/* hero header Text styling */
.hero-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.hero-header h2 {
  font-size: 20px;
  word-spacing: 4px;
  letter-spacing: 1;
  margin: 20px;
}

/* Pricing Container Styling */
.pricing-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 50px;
  flex-wrap: wrap;
}

/* Pricing Card Styling */
.pricing-card {
  background-color: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
  padding: 20px;
  text-align: center;
  width: 250px;
  transition: transform 0.3s ease-in-out;
}

.pricing-card:hover {
  transform: translateY(-10px);
}

/* Featured Plan Styling */
.pricing-card.featured {
  border: 2px solid #4caf50;
  background-color: #e8f5e9;
}

/* Pricing Title */
.pricing-title {
  font-size: 1.5em;
  font-weight: bold;
  margin-bottom: 15px;
}

/* Price Styling */
.price {
  font-size: 2em;
  color: #333;
  margin-bottom: 20px;
}

/* Features List Styling */
.features {
  list-style-type: none;
  margin-bottom: 20px;
}

.features li {
  margin-bottom: 10px;
  font-size: 1em;
  color: #555;
}

/* Button Styling */
.btn {
  background-color: #4caf50;
  color: #fff;
  padding: 12px 20px;
  border: none;
  border-radius: 5px;
  cursor: pointer;
  font-size: 1em;
  transition: background-color 0.3s;
}

.btn:hover {
  background-color: #45a049;
}

/* Responsive Design */
@media (max-width: 768px) {
  .pricing-container {
    flex-direction: column;
    align-items: center;
  }
}

Why this is important?

  • Flexbox is used to align the cards, ensuring that they are responsive and neatly stacked on smaller screens.
  • Hover effects make the cards more interactive.
  • The featured plan (the second card) is visually highlighted by adding a green border and a distinct background.
  • The media query ensures that the layout adapts to mobile screens, making it fully responsive.

Output:-


Conclusion:-

Stay Ahead in Your Tech Career 🚀

We don’t spam! Read our privacy policy for more info.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top