Stop using JS for things that CSS can solve

Kevin Powell on YouTubeWatch on YouTube

SaveMark complete

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

IntermediateUIWeb Design9 min

About this video

Shows how CSS pseudo-classes such as :empty, :target and :only-child can handle interface behaviour that is often coded in JavaScript. It suits front-end learners who already know basic CSS.

What you’ll learn

  • Style empty elements with the :empty pseudo-class
  • Use :target to show content linked from the URL
  • Select lone children with :only-child and :only-of-type