Yes—but selectively. The attribute selector ([attr], [attr="value"], [attr^="prefix"], and so on) is a standard, widely used part of day-to-day CSS, yet it is rarely the workhorse that class names, element types, and descendant combinators are. Most professional developers reach for attribute selectors regularly for a recognizable set of jobs—styling form controls, handling state and data hooks, targeting generated or third-party markup, and writing resilient component CSS—while using classes for the bulk of ordinary styling. The honest answer is "a lot in specific situations, not a lot everywhere."
The rest of this article explains where attribute selectors earn their place, where they cause trouble, and why the frequency varies so much between codebases and between individual developers.
What the attribute selector actually is
An attribute selector matches elements based on the presence or value of an HTML attribute rather than on a class or tag name. The common forms are:
| Form | Matches |
|---|---|
| [disabled] | Any element with a disabled attribute |
| [type="checkbox"] | Exact value match |
| [href^="https://"] | Value starting with a prefix |
| [href$=".pdf"] | Value ending with a suffix |
| [class*="btn-"] | Value containing a substring |
| [lang|="en"] | Exact match or match followed by a hyphen (the |= operator) |
| [data-state="open"] | A custom data attribute set to a specific value |
| [target="_blank" i] | Case-insensitive match (the i flag) |
There is also the s flag for forcing case-sensitive matching where the document language would otherwise be case-insensitive, though it is used far less often.
These selectors are part of CSS Level 2 and Level 3 and have been supported in every relevant browser for many years, so the syntax itself is not the limiting factor. The question is about practice, not capability.
Where attribute selectors are used heavily
Form controls
This is probably the single most common real-world use. Inputs and related elements carry meaningful attributes that map directly to visual or behavioral states:
Because type, disabled, required, readonly, checked, and placeholder are native attributes, targeting them lets CSS stay in sync with the actual semantics of the form. A developer does not have to add a parallel class for every state.
State and data hooks in component CSS
Modern component-driven development has made [data-*] selectors genuinely common. Frameworks and hand-written components frequently toggle data attributes to represent state:
This pattern is popular because data attributes are explicit, greppable, and let JavaScript change presentation without inventing a new class name for every state. It is one of the clearest places where attribute selectors are used "a lot" by teams that adopt the convention.
Styling markup you do not control
Third-party widgets, CMS output, markdown renderers, and email templates often emit attributes but few stable class names. Attribute selectors let you style what is actually there:
The link-decoration example is a classic: it distinguishes external links from internal ones using nothing but the href attribute.
Accessibility and language targeting
[lang|="fr"], [aria-hidden="true"], and [role="alert"] are legitimate, low-cost selectors that align CSS with accessibility semantics. They are not used constantly, but they appear in any stylesheet that takes internationalization or assistive-technology behavior seriously.
Attribute-driven utility and icon systems
Icon libraries and utility frameworks sometimes key off attributes—[data-icon], [aria-current="page"], and similar—which keeps the HTML expressive without proliferating classes. This is a real and growing use, though it depends heavily on team conventions.
Where attribute selectors are used sparingly
General layout and typography
Most ordinary styling still goes through classes and element selectors. A developer who needs a card layout, a grid, or a type scale will not usually reach for [class*="card"] or [data-layout]. Classes are concise, reusable, and easy to combine. Attribute selectors are comparatively verbose and often less expressive for pure presentational variation.
The substring operators are risky as design primitives
[class^="col-"], [class*="btn-"], and [class$="-primary"] look clever but are fragile. They couple CSS to naming conventions, break when a class name changes, and can match unintended combinations (for example, [class*="btn-"] also matches btn-secondary and any other class containing that substring). Using them as a systematic replacement for real classes is generally discouraged, and experienced developers tend to avoid them except for narrow, well-understood cases.
Performance is a minor but real consideration
Attribute selectors are not dramatically slow, but very broad attribute matching across a large DOM—especially substring matches—can be more expensive than class matching in some engines. For typical page sizes this is negligible. It becomes relevant in large, dynamic interfaces, and it is one reason teams keep attribute selectors targeted rather than using them as broad structural tools.
Specificity and maintainability
Attribute selectors carry class-level specificity (0,1,0, for a single attribute selector), so they interact with classes in the cascade in ways that can surprise people. Mixing [data-state="open"] rules with .is-open class rules can produce specificity conflicts that are annoying to debug. Teams that use them heavily usually adopt a strict convention about where they are allowed.
Why usage varies so much by project
The frequency of attribute selector use is less a matter of individual skill than of project context.
Design systems and component libraries tend to use them more, because data attributes and ARIA attributes provide a clean, framework-agnostic interface between markup and styling. Legacy or class-based CSS tends to use them less, relying on BEM-style classes and state classes instead. Utility-first frameworks typically discourage custom attribute selectors because the styling model is built around predefined utility classes. Email and CMS-adjacent work uses them more because the underlying HTML is unpredictable.
It also varies by developer. Some engineers have a mental model of "classes for style, attributes for semantics and state" and follow it closely, which produces steady attribute selector use. Others treat CSS as a pure class system, which produces almost none. Neither approach is inherently wrong; both are common in professional code.
The practical rule experienced developers tend to follow
A useful summary of mainstream practice is:
Use classes and element selectors for ordinary visual design. Use attribute selectors when the attribute already carries the meaning you need: form state, ARIA state, language, link destinations, or explicit data-* hooks. Avoid substring and prefix operators as a substitute for a real class system. Keep specificity in mind and adopt a convention so attribute-driven rules do not collide with class-driven ones.
That is why the answer to "do web developers use the attribute selector a lot?" is genuine but qualified. In the parts of CSS that deal with form controls, state, semantics, and third-party markup, attribute selectors are a normal and often frequent tool. In the bulk of everyday styling, they are the exception rather than the default.
A quick worked example
Consider a search component with a toggle button and a results panel. A developer might write:
This is a realistic pattern: the attributes carry state and accessibility meaning, and the CSS reads them directly. No new class is required for each visual state. It is exactly the kind of code that makes attribute selectors feel natural—and that shows why they appear frequently in state-heavy UIs.
Bottom line
Web developers use the attribute selector substantially in specific domains—form controls, state via data and ARIA attributes, external-link and language targeting, and styling markup they cannot change—and sparingly in general layout and typography, where classes remain the better tool. It is a well-supported, long-standing part of CSS that most professional developers know and use, but it is not the dominant selector in most stylesheets. The "a lot" claim is true locally and false globally, which is precisely why the question comes up.
Understanding that split is more useful than a yes-or-no verdict: it tells you when to reach for an attribute selector and when a class will serve you better.