Create a CSS only lightbox using :target

Kevin Powell on YouTubeWatch on YouTube

SaveMark complete

Sign in to save videos and track what you’ve finished.

IntermediateUI34 min

About this video

A tutorial showing how to build a lightbox effect with CSS alone, using the :target pseudo-class instead of JavaScript. It also covers the limitations of this approach when there are many items.

What you’ll learn

  • Build a lightbox that opens with the CSS :target pseudo-class
  • Compare CSS-only interactions with JavaScript-based ones
  • Recognise the limits of :target when a page has many items