HTML Cards
Organizing your webpage into card items.
Why use cards?
A card groups related information into a small, easy-to-scan unit. Cards are useful when a page has several items with a similar structure, such as activities, courses, or events. Repeating the same structure helps visitors compare items and helps you keep the page organized.
In the example, the div with the intensive class is the card. Its heading, image, description, and activity list all belong together. For independent, meaningful content, an article element can also be a good choice.
Build the card with HTML
HTML provides the card's content and structure. Add a class so CSS can select the card and style it:
<div class="intensive">
<h2>Winter Adventures</h2>
<img src="IMG_3391.JPG" width="200" alt="Gazing into the ocean from Wolfe's Neck">
<p>Ms. McCray and Ms. Lynch-Nichols</p>
<p>Feel the exhilaration of being immersed in the beauty of nature.</p>
<h4>ACTIVITIES</h4>
<ul>
<li>ice-skating</li>
<li>hiking</li>
<li>skiing</li>
</ul>
</div>
Style the card with CSS
CSS targets the .intensive class to give the card a background, border, rounded corners, and spacing. More specific selectors style elements inside it:
.intensive {
width: 100%;
max-width: 22rem;
margin: 0 auto;
padding: 1.25rem;
background-color: white;
border: 2px solid #63c6c7;
border-radius: 12px;
box-shadow: 0 8px 20px rgba(23, 75, 90, 0.12);
text-align: center;
}
.intensive h2 {
color: #174b5a;
}
.intensive img {
display: block;
width: 100%;
height: auto;
border-radius: 8px;
}
The . in .intensive means “select an element whose class is intensive.” The width and maximum width let the card shrink on a small screen without growing too wide on a larger one.
Open the complete examples
Open each example in Chrome to see the page as the browser displays it. The styled version includes CSS; the first version shows the HTML without card styling.