Something I thought I knew, but found out this week that I did not: the exact difference between pseudo classes and pseudo elements in CSS.
Pseudo classes let you style an element based on its state, says MDN (
:disabled). This also implicates that they refer to an existing element: something that is already in the DOM available to style.
Pseudo elements let you style things that are not actually elements. They can be parts of existing elements (
::first-line), including parts that exist temporarily (
::selection). Generated content also falls within the pseudo elements bracket (
Rachel Andrew said it beautifully at CSS Day 2017: “The more I know about CSS, the more I realise I don’t know” (photo: Bernardo Baquero)
Thanks Krijn for pointing me to this.