CSS in Practice

Uploaded : 3 months ago Updated : 3 months ago beginner

Take The Quiz

Take The Quiz

Let’s style for real

Apply what you learned: you’ll style a profile card from scratch and pick up a clean, maintainable workflow.

Project: a profile card

  • Write the HTML: a container with an image, a name and a short bio.
  • Link an external stylesheet and add a class on the card.
  • Style the box: padding, border-radius and a subtle shadow.
  • Use Flexbox to centre the card on the page.

The CSS

.card {
  max-width: 320px;
  margin: 40px auto;
  padding: 24px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 6px 20px rgba(0,0,0,.08);
  text-align: center;
}
.card img {
  width: 96px;
  height: 96px;
  border-radius: 50%;
  object-fit: cover;
}

Use the browser DevTools

Right-click → Inspect. You can tweak CSS live and see changes instantly before editing your file.

Good habits vs. common mistakes

Do ✓Don’t ✗
Reuse classes for repeated stylesRepeat the same rules everywhere
Use rem / % / Flexbox / GridHard-code pixel positions
Keep one external stylesheetScatter inline style attributes
Use box-sizing: border-boxFight unexpected widths

Watch out for these

A misspelled property is silently ignored, a missing unit (width: 100 instead of 100px) breaks layout, and overusing !important makes CSS unmaintainable.

The details are not the details. They make the design.Charles Eames
Why isn’t my CSS applying?
Check the <link> path, look for a typo in the selector or property, and inspect specificity — a more specific rule may be winning.
How do I centre a div?
With Flexbox on the parent: display:flex; justify-content:center; align-items:center;.
What’s next after CSS?
JavaScript — it makes your styled page interactive.

Keep going

You can now structure and style a page. Ready to make it interactive with JavaScript?

Explore the JavaScript track

Comments