🌐
W3Schools
w3schools.com › css › css_selectors.asp
CSS Selectors
This page will explain the most basic CSS selectors. The element selector selects HTML elements based on the element name. Here, all <p> elements on the page will be center-aligned, with a red text color: p { text-align: center; color: red; } Try it Yourself » · The id selector uses the id attribute of an HTML element to select a specific element.
🌐
GeeksforGeeks
geeksforgeeks.org › css › css-selectors
CSS Selectors - GeeksforGeeks
Attribute selectors in CSS target elements based on the presence or value of their attributes. 1. Presence Selector: It selects elements that contain a specific attribute. Example: styling all inputs with a type attribute.
Published   2 weeks ago
Discussions

What is the most common CSS selectors and properties you use?
This is of great relevance. https://www.chromestatus.com/metrics/css/popularity More on reddit.com
🌐 r/css
8
3
August 11, 2016
ELI5:CSS

HTML defines content, CSS decorates it and helps tell how it is displayed.

CSS stands for Cascading Stylesheet. This means that there is a hierarchy of style attributes overwriting other attributes that affect the same elements.

Think of it like this. Bob Ross does an oil painting and starts off with a canvas covered in liquid white. This is the lowest level on the hierarchy. It applies to the entire body of the painting, like a class applied to the body tag.

On that he paints some divs of class "mountain". The mountain class has the attribute paint-color:Van Dyke Brown. Since the div is within body the paint-color:Van Dyke Brown attribute overwrites the liquid white and you see the Van Dyke Brown over the liquid white.

He adds some divs of class "happy little tree" which are growing wherever they like, which happens to be on the mountains, so these happy little tree divs are within the mountain divs. Their paint-color:Sap Green is within the mountain div, so where the happy little tree divs are is painted with Sap Green on top of the Van Dyke Brown mountains.

Then Bob adds another happy little tree div. This one he wants to be Alizarin Crimson because its his world and it can be whatever fucking color he god damn pleases. Rather than giving it a special id and using the # selector Bob makes the happy little accident of using an inline style. This overwrites the happy little tree class's paint-color:Sap Green attribute with an inline paint-color:Alizarin Crimson because inline styles cascade over classes.

More on reddit.com
🌐 r/explainlikeimfive
9
19
July 5, 2012
CSS Selectors Cheatsheet
This is actually pretty nice. Thanks for sharing. More on reddit.com
🌐 r/css
11
62
May 19, 2018
CSS selectors

Probably less common than selecting by id or class, but useful nontheless.

There's a thing in CSS called "class-itis", which is a tendency of novices to put a class in every element and use them as selectors. The aim is to be selective enough, but if you over-use classes they become quite difficult to maintain.

Consider this

<div class="container">
<span>Heading</span>
<div>
<span>Hello world</span>
</div>
</div>

If we just did .container span { font-size : 20px; } it'd set the Hello World to be 20px as well as the heading. One solution might be to add in a "container-body" class on the nested div, but by using a specific descendant selector like .container > spanwe can limit the effect to just the heading and avoid the need for a second class whose job it is just to undo the effect of the more general rule.

More on reddit.com
🌐 r/learnprogramming
4
1
October 10, 2018
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Guides › Selectors › Selectors_and_combinators
CSS selectors and combinators - CSS | MDN
When combining a pseudo-class into a compound selector with a type or universal selector, the pseudo-class must follow the type selector or universal selector, if present. Not all CSS selectors are defined in the CSS selectors module. CSS pseudo-element selectors are defined in the CSS pseudo-elements module. CSS pseudo-elements, prefixed with two colons (::), represent entities that are not included in HTML. For example, the simple ::marker selector selects list item bullets, and the compound selector p::first-line matches the first line of all <p> elements.
🌐
Simmons University
web.simmons.edu › ~grabiner › comm244 › weekfour › selectors.html
CSS Selectors
The following is a list of the most common and well-supported CSS selectors. There are many, many more, but these are the ones you should know well. ... The most basic CSS selectors are Element Type Selectors.
🌐
Scale
scale.at › blog › css-selectors
Tutorial: CSS Selectors and Their Specificity | scale – your web solutions.
September 27, 2021 - All three CSS rules from above would apply to the header element because all three—the type selector, the class selector, and the ID selector—match. Obviously, an element can only have one background color. The winning color in this example is… drum roll 🥁 … darkseagreen, because the ID selector is the most specific of all three.
🌐
Programiz
programiz.com › css › selectors
CSS Selectors (With Examples)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <link rel="stylesheet" href="style.css" /> <title>CSS selectors</title> </head> <body> <h1>Heading</h1> <p>First Paragraph</p> <p>Second Paragraph</p> </body> </html> ... In the above example, the universal selector * selects all the HTML elements and applies the red color. Note: The universal selector is also referred to as the wildcard selector. The group selector allows you to select multiple elements and apply the same style to all of them.
🌐
W3C
w3.org › wiki › CSS › Selectors
CSS/Selectors - W3C Wiki
(MOVED) :only-of-type · (MOVED) :empty · (MOVED) :not · (MOVED) ::first-line · (MOVED) ::first-letter · (MOVED) ::before · (MOVED) ::after · (MOVED) A B · (MOVED) A > B · (MOVED) A + B · (MOVED) A ~ B · Selectors Level 3 Specification · CSS Educational Materials for Beginners ·
Find elsewhere
🌐
TutorialsPoint
tutorialspoint.com › css › css_selectors.htm
CSS - Selectors
CSS adjacent sibling selector selects an element that is immediately preceded by a specified element. A plus symbol ( "+" ) is used to denote adjacent sibling. The syntax of adjacent sibling selector is as follows:
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Learn_web_development › Core › Styling_basics › Basic_selectors
Basic CSS selectors - Learn web development | MDN
However, you should still consider using it in your code if you find it easier to understand. In this article, we've recapped CSS selectors, which enable you to target particular HTML elements, looking at type, class, and ID selectors in a bit more depth than we did previously.
🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Reference › Selectors › Type_selectors
Type selectors - CSS | MDN
November 7, 2025 - The CSS type selector matches elements by node name. In other words, it selects all elements of the given type within a document.
🌐
CSS-Tricks
css-tricks.com › css-selectors
CSS Selectors | CSS-Tricks
May 2, 2025 - Class selectors might be the most commonly used type of CSS selector you will see around the web. Classes are ideal because they are slightly more specific than element selectors but without the heavy-handedness of IDs.
🌐
SitePoint
sitepoint.com › blog › css › css selectors cheat sheet
CSS Selectors Cheat Sheet — SitePoint
November 13, 2024 - The ID CSS selector, declared using a hash symbol, targets any HTML element with a matching ID attribute, while the Class selector, declared with a dot, matches all elements with a matching class attribute. Pseudo-class and Pseudo-element selectors are special types of selectors that allow styling of specific parts of an element or elements in certain states, such as being hovered over or being the first child of their parent element.
🌐
Codecademy
codecademy.com › learn › fscp-web-development-fundamentals › modules › fecp-learn-css-selectors-and-visual-rules › cheatsheet
Web Development Fundamentals: Learn CSS: Selectors and Visual Rules Cheatsheet | Codecademy
CSS selectors define the set of elements to which a CSS rule set applies. For instance, to select all <p> elements, the p selector can be used to create style rules. CSS selectors can be chained so that rule sets apply only to elements that match all criteria. For instance, to select <h3> elements that also have the section-heading class, the selector h3.section-heading can be used. /* Select h3 elements with the section-heading class */ ... CSS type selectors are used to match all elements of a given type or tag name.
🌐
LearnWebCode
learnwebcode.com › home › blog › css lesson 3: basic css selectors
CSS Lesson 3: Basic CSS Selectors - LearnWebCode
March 29, 2016 - While there are many different types of CSS Selectors, today’s lesson focuses on the four essential selectors; Type, ID, Class and Descendant selectors. First We Need a Page To Style CSS isn’t very useful without a page to style.
🌐
Reddit
reddit.com › r/css › what is the most common css selectors and properties you use?
r/css on Reddit: What is the most common CSS selectors and properties you use?
August 11, 2016 -

I'm currently learning and I've heard the 80/20 rule (Pareto Principle) applies to CSS. So I want to make sure i really absorb and have a functional understanding of the useful stuff.

So which CSS selector do you use the most when building websites? For example div, classes, IDs, margin, float, color, etc.

🌐
MDN Web Docs
developer.mozilla.org › en-US › docs › Web › CSS › Guides › Selectors
CSS selectors - CSS | MDN
January 7, 2026 - ... Learn how to use the :target pseudo-class to style the target element a URL's fragment identifier. ... Explores the style limitations set on the :visited class for user privacy. ... Introduction to basic CSS selectors, including tutorials on Type, class, and ID selectors, Attribute selectors, ...
🌐
Codecademy
codecademy.com › learn › fecp-22-fundamentals-of-css › modules › wdcp-22-learn-css-selectors-and-visual-rules › cheatsheet
Fundamentals of CSS: Learn CSS: Selectors and Visual Rules Cheatsheet | Codecademy
CSS selectors define the set of elements to which a CSS rule set applies. For instance, to select all <p> elements, the p selector can be used to create style rules. CSS selectors can be chained so that rule sets apply only to elements that match all criteria. For instance, to select <h3> elements that also have the section-heading class, the selector h3.section-heading can be used. /* Select h3 elements with the section-heading class */ ... CSS type selectors are used to match all elements of a given type or tag name.
🌐
FFFuel
fffuel.co › css-selectors
CSS Selectors: A Visual Guide & Reference | fffuel
Visual guide to CSS selectors, including pseudo-classes (:nth-child, :hover,...), functional pseudo-classes (:not, :is,...) and pseudo-elements.
🌐
Soax
soax.com › glossary › css-selectors
What are CSS selectors and what are they used for?
There are several types of CSS selectors, each with its own way of targeting elements.