Tag: Canvas HTML Template cards

  • Card Component Design: Building Scannable Content Blocks

    Card Component Design: Building Scannable Content Blocks

    Visitors rarely read a page top to bottom. They scan, and the card is the component that makes scanning fast: one image, one heading, one short summary, one clear action.

    Key Takeaways

    • A scannable card has a fixed anatomy: media, label, heading, summary and a single action. Anything beyond that dilutes the scan.
    • Use Bootstrap 5’s row-cols-* classes with h-100 to get equal-height cards without custom JavaScript.
    • Theme cards with --cnvs-themecolor and --cnvs-primary-font so they follow your Canvas settings automatically.
    • Make the whole card clickable with stretched-link, and keep heading levels logical for accessibility.

    Why Cards Work for Scannable Content

    A card groups related information inside a visible boundary. That boundary tells the eye “this is one unit”, so users can compare blog posts, products, team members or pricing options without reading every word. Eye-tracking studies from Nielsen Norman Group have long shown that people scan pages in F-shaped or layer-cake patterns. Cards suit the layer-cake pattern particularly well because each card’s heading acts as an anchor.

    Cards are not always the right choice. For long-form reading, comparison tables with many attributes, or a list of 50 or more plain links, a card grid adds visual weight and slows the scan. Use cards when each item has an image or a distinct title plus a short summary and the user needs to choose between several items.

    Card Component Design: Building Scannable Content Blocks, abstract concept illustration

    The Anatomy of a Card That Gets Scanned

    Every effective content card contains the same five parts, in this order: media, category label, heading, summary and action. Limit the summary to roughly 15 to 25 words and use only one call to action. Two competing links on one card split attention and double the tap targets on mobile.

    Here is a clean Bootstrap 5 card. Canvas bundles Bootstrap 5, so these classes work without loading anything extra.

    <div class="card content-card h-100">
      <img src="images/blog/card-01.jpg" class="card-img-top"
           alt="Laptop showing a website grid layout"
           width="600" height="400" loading="lazy">
      <div class="card-body">
        <span class="card-category">Guide</span>
        <h3 class="card-title h5 mt-2">Designing a Pricing Page</h3>
        <p class="card-text">Three layout patterns that make plans easy to compare on any screen size.</p>
      </div>
      <div class="card-footer bg-transparent border-0 pt-0">
        <a href="#" class="stretched-link">Read the guide</a>
      </div>
    </div>

    Note the explicit width and height attributes on the image. They let the browser reserve space before the file loads, preventing layout shift, a common Core Web Vitals problem in card grids. For a deeper look at the Bootstrap card API, see Bootstrap 5 Cards: Building Flexible Content Containers.

    Building Responsive Card Grids

    A single card is easy. The hard part is a grid where cards line up when titles wrap to different lengths. Bootstrap’s row-cols-* classes set the column count per breakpoint, and h-100 on each card stretches it to the height of the tallest sibling.

    <div class="row g-4 row-cols-1 row-cols-md-2 row-cols-xl-3">
      <div class="col">
        <div class="card content-card h-100">
          <!-- card content -->
        </div>
      </div>
      <div class="col">
        <div class="card content-card h-100">
          <!-- card content -->
        </div>
      </div>
      <div class="col">
        <div class="card content-card h-100">
          <!-- card content -->
        </div>
      </div>
    </div>

    This gives one column on phones, two on tablets and three on desktops. Three columns is the practical ceiling for content cards with summaries. At four across, headings wrap awkwardly below 280px. If you want to preview column maths before committing, the Bootstrap Grid Calculator shows how each breakpoint divides the container. Keep g-4 (1.5rem gutters) or larger so shadows and borders do not visually merge.

    content cards web, abstract technical diagram

    Styling Cards With Canvas Variables

    Hard-coded hex values are the fastest way to make cards drift out of sync with the rest of a site. The Canvas HTML Template exposes --cnvs-themecolor, --cnvs-themecolor-rgb and --cnvs-primary-font, so a card can inherit your brand from one place. Add the following to your own stylesheet, loaded after style.css.

    .content-card {
      border: 1px solid rgba(var(--cnvs-themecolor-rgb), 0.15);
      border-radius: 0.75rem;
      overflow: hidden;
      transition: transform 0.2s ease, box-shadow 0.2s ease;
    }
    
    .content-card .card-img-top {
      aspect-ratio: 3 / 2;
      object-fit: cover;
    }
    
    .content-card .card-category {
      color: var(--cnvs-themecolor);
      font-size: 0.75rem;
      font-weight: 600;
      letter-spacing: 0.08em;
      text-transform: uppercase;
    }
    
    .content-card .card-title {
      font-family: var(--cnvs-primary-font);
    }
    
    .content-card:hover,
    .content-card:focus-within {
      transform: translateY(-4px);
      box-shadow: 0 12px 28px rgba(0, 0, 0, 0.12);
    }
    
    @media (prefers-reduced-motion: reduce) {
      .content-card { transition: none; }
      .content-card:hover,
      .content-card:focus-within { transform: none; }
    }

    The aspect-ratio rule is what keeps a grid tidy when editors upload photos of different proportions. To fine-tune the lift effect, try the CSS Box Shadow Generator, and use the CSS Border Radius Generator to match corner radii to your buttons and inputs. Change --cnvs-themecolor in Canvas and every category label updates with it automatically.

    Accessibility and Common Mistakes

    Most card problems are not visual. They are structural. Check these six points before shipping:

    1. One link per card. Use stretched-link on the main action so the whole card is clickable, rather than wrapping the card in an anchor with nested links.
    2. Logical heading levels. If the section heading is an h2, card titles should be h3. Use the h5 utility class for size, not a real h5 tag.
    3. Meaningful alt text. Describe the image, or use alt="" if it is purely decorative.
    4. Visible focus states. The :focus-within rule above ensures keyboard users see the same emphasis as mouse users.
    5. Consistent image ratios. Mixed ratios make a grid look broken even when the code is correct.
    6. Link text that makes sense alone. “Read the guide” is better than “Click here”, and “Read the pricing guide” is better still.

    Card grids also work well in blog indexes. For a full listing layout built around them, see Canvas Blog Templates: Setting Up the Perfect Content Layout. If you would rather generate a card section than hand-write it, Canvas Builder produces Canvas-ready markup from a plain-language description. Specifying the number of cards, the content of each and the breakpoint behaviour gets far better output, as covered in 5 Types of AI Prompts That Generate the Best HTML Layouts.

    Frequently Asked Questions

    How many cards should I show in a grid?

    Show 6 to 9 cards before offering pagination or a “load more” button. That fills two or three rows on desktop, which is enough to scan comfortably without forcing long scrolling.

    Should the whole card be clickable?

    Yes, in most cases. Bootstrap’s stretched-link class extends one anchor’s click area across the card. Avoid placing several independent links inside a stretched card, because they will conflict.

    How long should card text be?

    Keep headings under about 60 characters and summaries to 15 to 25 words. If your content needs more, link to the full page rather than lengthening the card.

    Do I need to load Bootstrap separately to use cards in Canvas?

    No. Canvas is built on Bootstrap 5 and bundles it, so card, grid and utility classes work out of the box. Loading a Bootstrap CDN as well would duplicate styles and can cause conflicts.

    How do I stop card images from distorting?

    Set aspect-ratio on the image with object-fit: cover, and include width and height attributes. Images are then cropped consistently instead of stretched, and the layout does not shift as they load.

    If you’re working with the Canvas HTML Template and want to generate production-ready layouts faster, try Canvas Builder free and see how much time you save on every project.

  • Bootstrap 5 Cards: Building Flexible Content Containers

    Bootstrap 5 Cards: Building Flexible Content Containers

    Cards are the most reused component in any Bootstrap landing page, yet most developers stop at the default image-title-button stack. Used well, Bootstrap 5 cards become a flexible system for features, pricing, testimonials, blog teasers and portfolio items.

    Key Takeaways

    • Combine row-cols- with h-100 on each card to get equal-height responsive grids without custom CSS.
    • Use stretched-link and object-fit-cover to make whole cards clickable and keep images consistent.
    • Override Bootstrap’s –bs-card- variables and Canvas’s –cnvs-themecolor instead of fighting specificity.
    • Bootstrap 5 has no built-in masonry layout, so choose cards in a grid when you need predictable rows.

    Card Anatomy and the Markup That Matters

    A Bootstrap card is a bordered flex column container with optional header, image, body, list group and footer. The only required parts are .card and, usually, .card-body. Everything else is opt-in, which is what makes the component so adaptable for a Bootstrap content layout.

    <div class="card" style="max-width: 22rem;">
      <img src="images/feature.jpg" class="card-img-top" alt="Dashboard preview">
      <div class="card-body">
        <h3 class="card-title h5">Analytics Dashboard</h3>
        <p class="card-text">Track traffic, conversions and revenue in one view.</p>
        <a href="#" class="btn btn-primary">View details</a>
      </div>
    </div>

    Notice the h5 utility class on an h3. Card titles should follow your page’s heading hierarchy for SEO and accessibility, while the visual size is handled separately. The Bootstrap 5 typography guide covers these size utilities in more depth.

    Bootstrap 5 Cards: Building Flexible Content Containers, abstract concept illustration

    Building Responsive Card Grids with row-cols

    The fastest way to lay out cards is the row-cols system. Declare how many columns you want per breakpoint on the row, and Bootstrap sizes every child column for you. Add h-100 to each card and all cards in a row match the tallest one.

    <div class="container py-5">
      <div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
        <div class="col">
          <div class="card h-100">
            <div class="card-body">
              <h3 class="card-title h5">Fast Setup</h3>
              <p class="card-text">Launch a page in minutes, not days.</p>
            </div>
          </div>
        </div>
        <div class="col">
          <div class="card h-100">
            <div class="card-body">
              <h3 class="card-title h5">Responsive</h3>
              <p class="card-text">Looks right from 320px to 1920px.</p>
            </div>
          </div>
        </div>
        <div class="col">
          <div class="card h-100">
            <div class="card-body">
              <h3 class="card-title h5">Customisable</h3>
              <p class="card-text">Change colours and fonts from one place.</p>
            </div>
          </div>
        </div>
      </div>
    </div>

    The gutter class g-4 handles spacing in both directions, so you never need manual margins between cards. The Bootstrap Grid Calculator is a quick sanity check for how columns divide at each width. For how md and lg map to real screen widths, see the Bootstrap 5 breakpoints explained guide.

    Card Patterns for a Bootstrap Landing Page

    Different landing page sections need different card behaviour. These four patterns cover most real projects:

    1. Feature cards: icon, short title, two lines of copy. No border, no button. Keep them scannable.
    2. Pricing cards: a header with the plan name, a list group of inclusions, and a full-width button in the footer. Highlight the recommended plan with border-primary or a themed border.
    3. Testimonial cards: a blockquote in the body and a name with avatar in the footer.
    4. Content teasers: image on top, category label, title, and a clickable area spanning the whole card.

    For the teaser pattern, stretched-link extends the link’s clickable area across the entire card. That matters for mobile tap targets, where a small “Read more” link is genuinely hard to hit:

    <div class="card h-100 border-0 shadow-sm">
      <div class="ratio ratio-16x9">
        <img src="images/post.jpg" class="card-img-top object-fit-cover" alt="Team reviewing a layout">
      </div>
      <div class="card-body">
        <span class="badge text-bg-light mb-2">Guide</span>
        <h3 class="card-title h5">
          <a href="/blog/post" class="stretched-link text-decoration-none text-reset">How to plan a landing page</a>
        </h3>
        <p class="card-text text-body-secondary">A section-by-section checklist.</p>
      </div>
    </div>

    The ratio wrapper plus object-fit-cover (available in Bootstrap 5.3) keeps every thumbnail the same shape even when source images differ. One important constraint: only use one stretched-link per card. Multiple links in the same card compete for the same clickable area. If you are using cards for work samples, the same teaser pattern drives the grid in our portfolio website tutorial.

    Bootstrap content layout, abstract technical diagram

    Customising Cards Without Fighting Specificity

    Since Bootstrap 5.2, the card component exposes CSS variables such as --bs-card-spacer-y, --bs-card-spacer-x, --bs-card-border-radius and --bs-card-bg. Override those on a modifier class rather than rewriting selectors. In the Canvas HTML Template, brand colour comes from --cnvs-themecolor (with an RGB twin, --cnvs-themecolor-rgb), so your hover states stay in sync with the rest of the site.

    .card-feature {
      --bs-card-spacer-y: 1.75rem;
      --bs-card-spacer-x: 1.5rem;
      --bs-card-border-radius: 1rem;
      border-color: transparent;
      transition: transform .2s ease, box-shadow .2s ease;
    }
    
    .card-feature:hover {
      transform: translateY(-4px);
      box-shadow: 0 .75rem 1.5rem rgba(var(--cnvs-themecolor-rgb), .18);
    }
    
    .card-feature .card-title a:hover {
      color: var(--cnvs-themecolor);
    }
    
    @media (prefers-reduced-motion: reduce) {
      .card-feature { transition: none; }
      .card-feature:hover { transform: none; }
    }

    Because Canvas bundles Bootstrap 5, do not add a separate Bootstrap CDN link to use any of this. Add your overrides to a custom stylesheet loaded after style.css. To fine-tune the shadow value visually, the CSS Box Shadow Generator saves guesswork.

    Limits of Cards and When to Choose Something Else

    Cards are not always the right container. Know the constraints before committing:

    • No masonry: Bootstrap 5 dropped its card-columns masonry layout. If your cards have wildly different heights and you want them packed tightly, you need the Masonry JS library or CSS grid, otherwise you get uneven gaps.
    • Too many cards flatten hierarchy: if every section is a grid of three identical boxes, nothing stands out. Alternate cards with full-width bands, split layouts and large typography.
    • Long text: cards suit 20 to 40 words of body copy. Longer content belongs in a standard column or an accordion.
    • Mobile stacking: a six-card grid becomes six screens of scrolling at row-cols-1. Consider row-cols-2 on small screens for compact items such as logos or icons.

    Hand-coding every variant is where time disappears. With Canvas Builder, you describe the section you need and get Canvas-ready markup using the right classes and variables, which is a faster route than assembling cards by hand for every page.

    Frequently Asked Questions

    How do I make all Bootstrap 5 cards the same height?

    Place the cards in a row with row-cols-* classes and add h-100 to each .card. The columns stretch to equal height and the cards fill them.

    What is the difference between card-group and a row of cards?

    .card-group joins cards into one attached unit with equal heights and no gutters, and it collapses to a vertical stack on small screens. A grid with row-cols gives you gutters, per-breakpoint column counts and more control, so it is the better choice for most landing pages.

    Can I make an entire card clickable?

    Yes. Add the stretched-link class to one link inside the card, and make sure the card has position: relative, which Bootstrap applies by default. Avoid placing other interactive elements in the card unless you raise their z-index.

    How do I change card colours to match my brand in Canvas?

    Set your brand colour through --cnvs-themecolor and reference it in your card hover and accent styles. Use --cnvs-themecolor-rgb when you need transparency, as in rgba(var(--cnvs-themecolor-rgb), .15).

    Are Bootstrap cards good for SEO?

    Cards are just semantic-neutral containers, so SEO depends on your content. Use real heading tags for titles, descriptive alt text on images and crawlable links. Our guide to SEO-optimised HTML landing pages covers the wider checklist.

    If you’re working with the Canvas HTML Template and want to generate production-ready layouts faster, try Canvas Builder free and see how much time you save on every project.