HTML and CSS · Lesson 12 of 12

Project: a responsive profile card

Time to put it together: a profile card you could put on a portfolio, built from semantic HTML and the CSS from every lesson. Then change it to make it yours.

The card

Semantic HTML for the content (an article with a heading, a paragraph, a list of skills and links), the box model for spacing, flexbox for the rows, variables for the colours, and a transition for the hover. Read it top to bottom, then start changing things: the name, the colours, the radius, the skills.

Try itEdit the code: the page updates as you type

Make it yours

  • Change --brand to your colour, and the avatar, the skills and the buttons all follow.
  • Add a dark version: a .dark class that redefines the variables, as in lesson 11.
  • Add a third link and watch flexbox share the space.
  • Put three cards in a grid with repeat(auto-fit, minmax(280px, 1fr)), as in lesson 9.

When you're happy, put it on GitHub Pages or any free host: your first deployed page.

Your turn

Add a "Open to work" badge to the top-right corner of the card (lesson 7), and make the card switch to a dark theme when it has the class dark (lesson 11).

ExerciseEdit the code: the page updates as you type
Show a solution
<style>
  :root { --bg: white; --text: #0b1220; }
  .dark { --bg: #0b1220; --text: #e8edf5; }
  .card { position: relative; max-width: 300px; padding: 20px; border: 1px solid #ccc; border-radius: 14px; background: var(--bg); color: var(--text); }
  .badge { position: absolute; top: 12px; right: 12px; background: #2b8a3e; color: white; font-size: 12px; padding: 2px 8px; border-radius: 99px; }
</style>
<article class="card dark">
  <span class="badge">Open to work</span>
  <h1>Your Name</h1>
  <p>Web developer</p>
</article>

In the interview

How would you build a theme switcher?

Put every colour in CSS variables on :root, redefine them under a class or attribute (like [data-theme="dark"]), and toggle that on the html element with a little JavaScript, saving the choice in localStorage. Respect prefers-color-scheme for the default.

How do you make a card layout responsive?

A grid with repeat(auto-fit, minmax(…, 1fr)) for the cards, flexbox inside each card, max-width on images, and relative units, so the layout adapts without many media queries.

What would you check before shipping a page?

It works at 320px and on desktop, keyboard navigation and focus styles work, images have alt text and sizes, colours have enough contrast, headings are in order, and the page passes a Lighthouse audit.

Your progress stays on this device.