HTML & CSS · Beginner · 20 min
Make a featured card span the grid
Use grid lines to span columns while keeping a sensible reading order.
Count grid lines
Grid lines mark track boundaries. Two columns have three column lines. The grid-column property sets an item’s start and end lines. Use grid-column: 1 / -1 to stretch a featured card from the first to the last line of the explicit grid, even when the column count changes.
<style>
.projects { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.featured { grid-column: 1 / -1; }
</style>
<div class="projects">
<article class="featured">Weekend walk</article>
<article>Study notes</article>
<article>Recipe book</article>
</div>Expected appearance
[ Weekend walk ] [ Study notes ][ Recipe book ]
Keep reading order meaningful
Keep the featured article first in the HTML. Stack all three articles on narrow screens. On wider screens, use two columns and let the remaining articles share the next row. CSS placement changes the visual layout, not the document’s reading or keyboard order. Avoid rearranging content that has a meaningful sequence.
.projects { display: grid; grid-template-columns: 1fr; gap: 16px; }
.featured { grid-column: 1 / -1; }
@media (min-width: 600px) {
.projects { grid-template-columns: 1fr 1fr; }
}Expected appearance
320px: 1 768px: 2 .featured: 1 / -1
Try it yourself
Code runs on this device. When you are signed in, drafts sync to your account.
Edit the page content and include CSS in a style element. The preview supports a limited set of HTML elements. Scripts, external resources, navigation to other sites, and form submission are disabled.
Build and check
Keep the three <article> elements in .projects, with .featured first and a 16px gap. Use one grid column at 320px and two at 768px. Set grid-column: 1 / -1 on .featured at both widths. Leave the other articles automatically placed and keep all three within the viewport.
Add grid-column: 1 / -1 to .featured. Inside @media (min-width: 600px), give .projects two equal columns.
Show worked solution
<style>
* { box-sizing: border-box; }
main { max-width: 720px; margin: 0 auto; padding: 16px; font-family: sans-serif; line-height: 1.5; }
.projects { display: grid; grid-template-columns: 1fr; gap: 16px; }
.projects > article { padding: 16px; border: 1px solid #64748b; overflow-wrap: anywhere; }
.featured { background-color: #eff6ff; }
.featured { grid-column: 1 / -1; }
@media (min-width: 600px) {
.projects { grid-template-columns: 1fr 1fr; }
}
</style>
<main>
<h1>My projects</h1>
<div class="projects">
<article class="featured"><h2>Weekend walk</h2><p>A route to share with friends.</p></article>
<article><h2>Study notes</h2><p>Ideas from this week.</p></article>
<article><h2>Recipe book</h2><p>Meals I enjoy making.</p></article>
</div>
</main>The featured article spans the explicit grid at both widths. The two later articles stack on narrow screens and share the next row on wider screens. Their HTML order stays the same.
Page preview
Run to preview your page. Check tests the task requirements, including the requested screen widths. Check results do not replace keyboard and visual review.
Try it yourself
- Preview the finished layout at narrow and wide widths. The featured card should fill the first row in both.
- Compare the HTML order with the visual order. Keep the featured article first and the two other articles after it.