← Back to CSS
30

Drawing with CSS: shapes, layers and composition

Create simple illustrations with CSS using borders, pseudo-elements, gradients and transforms.

📘 Theory

Basic shapes

Start with circles, triangles and capsules before composing larger scenes.

1

A circle is just a square box with `border-radius: 50%`.

2

The classic triangle comes from borders when the element has zero width and height.

3

Once those fundamentals feel natural, transforms and gradients let you create much richer shapes with surprisingly little code.

Composing with pseudo-elements

One HTML tag can still produce several visual parts.

1

`::before` and `::after` let you attach secondary shapes without creating more DOM nodes.

2

That makes them especially useful for decorative cards, badges, icons and playful interface accents.

🧪 Learn by doing

Example Demo: planet icon Build a planet with a ring using one pseudo-element.

🏁 Challenges

Challenge Challenge: minimal face with CSS Add eyes with `::before` and `::after`.

🧰 Resources

Test

Check your knowledge with a test about CSS.

Test for CSS

What is this?

I'm Cristian Eslava and I sometimes build websites so both you and I can learn and experiment. culTest

I made this in February 2026 to make learning easier for my students. The idea is to learn web development by practicing and to keep expanding the project with new topics, tests and challenges.

It draws inspiration from MDN, W3Schools, CodePen, Manz and many other web development references. I wanted to combine useful theory, runnable examples, challenges and the testing system I had already built for culTest. culTest

If you liked it, if you didn't, or if you want to get in touch, write to me at cristianeslava@gmail.com