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.
Sensory-Minds GmbH
Offenbach am Main, Germany
Remote
Senior
JavaScript
Node.js
+3
Matching moments
03:31 MIN
Understanding the DOM structure and pseudo-elements
View-Transition-API: Gamechanger for hybrid app-development
18:32 MIN
The rise of natively stylable HTML components in CSS
WeAreDevelopers LIVE - Yes, CSS Can Do That!
08:26 MIN
Pushing the boundaries of CSS as a programming language
WeAreDevelopers LIVE - CSS is DOOMed
08:04 MIN
Evolving CSS from basic styles to advanced effects
How to write a book with CSS
09:58 MIN
Rediscovering HTML elements and upcoming CSS features
WeAreDevelopers LIVE - Can AI save Accessibility?; Horrid HTML; The Frontend Treadmill and more
08:07 MIN
Exploring modern JavaScript performance and new CSS features
WeAreDevelopers LIVE – AI, Freelancing, Keeping Up with Tech and More
11:20 MIN
A tour of creative code demos and useful developer tools
WeAreDevelopers LIVE – PHP Is Alive and Kicking and More
10:00 MIN
Building resilient and performant CSS-only components
NoLoJS - Avoiding JavaScript Cruft with HTML and CSS - Aaron T. Grogg
Featured Partners
Related Videos
WeAreDevelopers LIVE - Yes, CSS Can Do That!
Chris Heilmann, Daniel Cranney & Zoran Jambor
What's new in CSS for Designers?
Onur Gumus
WeAreDevelopers LIVE - CSS is DOOMed
Chris Heilmann, Daniel Cranney & Justin Halsall & Christian Schaefer
Playing Games with CSS
Elad Shechter
WeAreDevelopers LIVE – Spicy Vanilla Web, CSS Magic & More
Chris Heilmann, Daniel Cranney & Peter Kröner
Can CSS recreate Tufte's designs?
Håkon Wium Lie
How to write a book with CSS
Håkon Wium Lie
Kirsty's Excellent Adventure in CSS Grid
Kirsty Burgoine
Related Articles
View all articles



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


&why GmbH
Berlin, Germany
€50-70K
Junior
Intermediate
Senior
React
Next.js
TypeScript

Working Class Heroes
Dordrecht, Netherlands
Senior
CSS
Adobe Flash
ActionScript
Adobe Photoshop

CSS AG
Künzell, Germany

Unusualtechnologies
Brighton and Hove, United Kingdom
£26-32K
Junior
PHP
.NET
Linux
Laravel


O&O Software GmbH
Ansfelden, Austria
€43K
CSS
WebGL
React
jQuery
+2

Digital Concepts, Novak - Winkler OG
Linz, Austria
Remote
€42-70K
CSS
JavaScript
Machine Learning
