Change the style of an input based on if there is a placeholder

Kevin Powell on YouTubeWatch on YouTube

SaveMark complete

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

IntermediateUI7 min

About this video

Shows how the CSS :placeholder-shown pseudo-class can style an entire form input depending on whether its placeholder is visible. It contrasts this with ::placeholder, which only styles the placeholder text itself.

What you’ll learn

  • Style an input differently while its placeholder is showing
  • Compare :placeholder-shown with the ::placeholder pseudo-element