Dan Cranney
Tips and Tricks: CSS Pseudo Class Selectors and Pseudo Elements
#1about 1 minute
Differentiating between CSS pseudo-classes and pseudo-elements
Learn the key difference between pseudo-classes, which style elements in specific states, and pseudo-elements, which style specific parts of an element.
#2about 1 minute
Simplify complex CSS selectors with the :is pseudo-class
Use the :is() pseudo-class to group multiple selectors and apply shared styles in a more compact and readable way.
#3about 1 minute
Style elements based on a checkbox state with :checked
Update the styles of sibling elements based on the state of a checkbox input using the :checked pseudo-class, without any JavaScript.
#4about 1 minute
Create a pure CSS tooltip with :hover and sibling selectors
Combine the :hover pseudo-class with the next sibling selector (+) to show and hide a tooltip element on button hover.
#5about 1 minute
Conditionally style parent elements using the :has pseudo-class
Apply styles to a parent element only when it contains specific child elements by using the :has() pseudo-class selector.
#6about 1 minute
Insert placeholder content into empty elements with CSS
Use the :empty pseudo-class combined with the ::before pseudo-element to dynamically insert placeholder text into empty divs.
#7about 2 minutes
Create a skewed highlight effect with the ::before pseudo-element
Implement a dynamic, skewed background highlight for text by inserting and styling content with the ::before pseudo-element.
#8about 1 minute
Create newspaper-style text with ::first-line and ::first-letter
Combine the ::first-line and ::first-letter pseudo-elements to apply unique typographic styles for a classic drop cap and introductory line effect.
Related jobs
Jobs that call for the skills explored in this talk.
Douglas GmbH
DĂĽsseldorf, Germany
Intermediate
Senior
TypeScript
React
Matching moments
03:17 MIN
Selecting strategic partners and essential event tools
Cat Herding with Lions and Tigers - Christian Heilmann
04:49 MIN
Using content channels to build an event community
Cat Herding with Lions and Tigers - Christian Heilmann
04:57 MIN
Increasing the value of talk recordings post-event
Cat Herding with Lions and Tigers - Christian Heilmann
01:32 MIN
Organizing a developer conference for 15,000 attendees
Cat Herding with Lions and Tigers - Christian Heilmann
02:54 MIN
Automating video post-production with local scripts
Cat Herding with Lions and Tigers - Christian Heilmann
02:44 MIN
Rapid-fire thoughts on the future of work
What 2025 Taught Us: A Year-End Special with Hung Lee
11:32 MIN
The industry's focus on frameworks over web fundamentals
WeAreDevelopers LIVE – Frontend Inspirations, Web Standards and more
03:35 MIN
Building a one-time code input with semantic HTML
WeAreDevelopers LIVE – Frontend Inspirations, Web Standards and more
Featured Partners
Related Videos
What's new in CSS for Designers?
Onur Gumus
What’s New and What’s Next in Web UI
Cleyra Uzcategui
WeAreDevelopers LIVE - Web Typography; CSS Layout features; Staying curious in an AI world and more
Chris Heilmann, Daniel Cranney & Jason Pamental
WeAreDevelopers LIVE – Frontend Inspirations, Web Standards and more
Chris Heilmann, Daniel Cranney & Jan Deppisch
Catching up on the basics you don't really need that much code
Chris Heilmann
Playing Games with CSS
Elad Shechter
Angular tips/tricks you can use from tomorrow on
Benedikt Starzengruber
Tips and Tricks for Working with JSON
Dan Cranney
Related Articles
View all articles



From learning to earning
Jobs that call for the skills explored in this talk.

Agora Think Tanks gGmbH
Berlin, Germany
Intermediate
Senior
PHP
CSS
HTML
JavaScript
TypeScript





Tech Solutions Gmbh
Berlin, Germany
API
CSS
GIT
HTML
Scrum
+5



Tech Solutions Gmbh
Brandenburg an der Havel, Germany
API
CSS
GIT
HTML
Scrum
+5