← Web basics: HTML, CSS and JavaScript

Project: a profile card

HTML structure plus CSS box model and flexbox.

Start this lesson

A profile card shows a person at a glance: photo, name, role and a link. It is a perfect first project because it uses meaningful HTML (an article with a heading, an image with alt text, a link) and the CSS you know: padding and border from the box model, rounded corners, and flexbox to put the photo beside the text. Build it in layers: structure first, then box styles, then layout.

<article class="card">
  <img src="kwame.jpg" alt="Kwame holding a guitar">
  <div>
    <h2>Kwame Mensah</h2>
    <p class="role">Music teacher</p>
  </div>
</article>

.card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 16px;
  border: 1px solid #ccc;
  border-radius: 12px;
}
.card img {
  width: 80px;
  border-radius: 50%;
}

The card is a flex container, so the image and the text block sit side by side, centered vertically with 16px between them. border-radius: 50% turns the square photo into a circle.

article fits a card because a card makes sense on its own. Inside it, the name is a heading so screen reader users can jump between cards.

Grouping the name, role and link in one div makes them a single flex item, so they stay stacked together beside the photo.