/

Simple lightbox with just a little JS and CSS

Jun 3, 2026

The /projects page includes screenshots of my projects but clicking them used to simply redirect to the project URL. This has always bugged me, but I didn’t want to add a dedicated lightbox library as I hate adding unnecessary libraries to projects.

I figured there must be an easy way to do it with just CSS + simple JS and it turns out, there is!

<dialog>

The first part of the puzzle is the <dialog> element.

<dialog>
  <h1>This is my modal</h1>
</dialog>

It’s used to represent modals and non-modal dialog boxes, which is exactly what we need.

Discuss this post on Twitter →
[ shameless plug ]
Psst. Check out my latest project, Nadir, for fun trivia and technical quizzes.