CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress
- Tags: Pseudo-Class, Selector, Text
- Categories: CSS Reference, CSS Selectors, Reference
Last Updated on November 12, 2022
Quick Reference
The :link selector is used to select unvisited links, and will NOT style links you have already visited.
/* selects every HTML link that has not been visited */
a:link {
background-color: black;
}
Additional Info
Selecting Multiple Elements
Note
To select multiple HTML elements with varying ids and classes, separate them with commas.
#intro, #footer, .my_paragraphs, h3 { background: white; }
Increasing Specificity
Note
To be more specific when selecting an HTML element, you can refer to the element and an ancestor element (.grandfather .child or #father .child or .grandfather h1 or any number of combinations). Note that there is no comma between the classes (.grandfather .child) which says you are targeting the class .child and it must have an ancestor with the class .grandfather. You can include as many ancestors as necessary to be as specific as necessary.
.grandfather #son .child p { background: white; }
Note
To select an HTML element that may have multiple classes attached, you can be more specific by including more than one class (or even adding an #id or tag name) to point to that one element: .my_paragraph.secondary_paragraph { }. Note that there are no spaces between the classes because they belong to the same element. This would ONLY select an element that has both classes: .my_paragraph and .secondary_paragraph.
h1.intro, p#footer, h1#header.primary, #sidebar#topper.image { background: white; }
We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.
CSS
HTML
JavaScript
jQuery
PHP
SQL
WordPress
Why 1SMARTchicken?
This site was built and is maintained to benefit my autistic son.
See More →
See More →
Thanks for your support!
CSS Books
All are affiliate links. Thank you for your support!
CSS NOTES:
- The “inherit”, “initial” and “unset” keywords can be used with any CSS property to set its value
- In CSS there are many ways to express a color value in a property
Feedback
If you see an error on the page or the code itself is incorrect or incomplete, or just plain wrong, please let us know. We’re always learning. NOTE: we do not sell your information and will not send you spam emails.