Cards and Containers

Introduction
Cards and containers are essential parts of modern web design. They help organize content, improve layout, and make websites visually appealing. Understanding how to use them properly is important for every beginner in CSS.

What is a Container
A container is a layout element that holds other elements such as text, images, buttons, or cards. It helps control the width, alignment, and spacing of content on a webpage.

Purpose of Containers
Containers keep content structured and centered on the page
They control the maximum width of content
They create consistent spacing and alignment
They improve readability on different screen sizes

Basic Container Example
.container {
width: 80 percent
margin: auto
}

What is a Card
A card is a small box used to display information in a clean and organized way. Cards are commonly used for products, profiles, blog posts, and services.

Purpose of Cards
Cards group related information together
They make content easy to scan
They improve visual design and user experience
They can include images, text, and buttons

Basic Card Example
.card {
border: 1px solid lightgray
padding: 20px
margin: 10px
border radius: 8px
}

.card h3 {
margin bottom: 10px
}

.card p {
font size: 14px
}

Combining Cards with Containers
Containers are used to hold multiple cards in a structured layout. Cards can be arranged in rows using flexbox or grid.

Example Layout
.container {
display: flex
gap: 20px
}

.card {
width: 200px
}

Best Practices
Keep card design simple and consistent
Use enough spacing between cards
Make cards responsive for mobile devices
Use clear headings and readable text
Avoid too much content inside a single card

Conclusion
Cards and containers are powerful tools in web design. Containers manage layout while cards present content in a clean and structured way. Mastering both will help you build modern and professional websites.