Issue #6 - CSS Selectors and Reference Guide
Writing CSS is basically selecting an HTML element and applying a style to it. When starting out, you’re probably using mostly type and class selectors.
Throw in some descendant combinators and that should take care of most of your needs.
But there are more selectors that you might find useful. For example, a pseudo-class selector that I use quite often is :hover
which refers to the when the user holds the mouse point over an element, usually a link. But there are plenty more pseudo-classes (about 50+ actually!) that you can use to select elements based on a user action (e.g. mouse hover) or its position in the document tree and its surrounding elements.
For example, :first-child
and :last-child
selects the first or last element in a group of sibling elements.
If you want to get really fancy, you can use the :nth-child()
pseudo-class which uses a keyword, a number, or an algebraic expression to select a specific element or group of elements
The keywords
odd
oreven
match to every other elementA number will match to that specific child element
The algebraic expression (
An+B
) is used to match to a specific pattern
To learn more about these selectors or if you just want to support my work, grab my 11-page CSS Selectors Reference Guide (PDF). It’s free to download but you can also leave a little something extra. 😉
Also, don't forget to check out my YouTube channel! I need 4000 watch hours to join the YouTube partner program and… I’m not there yet. 🙂
You can also check out all my courses on LinkedIn Learning too!
---
On a personal note: I had gallbladder surgery about month ago and that literally forced me to slow down. I was frustrated at first about how slow the recovery process was. I figured that since I just do desk work, I would be okay. But even though my days were pretty sedentary, I found that I still needed to take frequent breaks and so my workdays were a lot shorter. Deadlines I had created needed to be pushed back. I had to accept that things just need to happen on their own time. But I'm glad I was able to get this monthly newsletter article out right on the last day of this month.🙂
Thanks for reading!