Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more

If a CSS triangle vanished after a stylesheet change, inspect selectors that use the attribute substring operator *=. For example, [class*="triangle"] matches when “triangle” occurs anywhere in the complete class attribute value—including inside a longer class name. That is different from checking whether “triangle” is a whole class token. The title identifies substring matching as the incident’s cause, but without its HTML and CSS, the exact declaration that hid the triangle cannot be determined.

Why can a selector match the wrong class?

CSS attribute selectors test an attribute’s value in different ways. The operator *= means “contains this substring somewhere”; it does not mean “this class name is one complete item in the class list.” MDN defines [attr*=value] as matching an attribute value that contains at least one occurrence of the supplied value.

For example, given <div class="icon-triangle-alert">, the selector [class*="triangle"] matches: the substring appears in the class attribute value. But [class~="triangle"] does not match, because triangle is not a complete whitespace-separated class token. This example demonstrates selector behavior; it does not establish the markup or selector in the incident.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use *= when finding a substring anywhere in an attribute is intentional. When the attribute is a class list and the intent is to select a particular class token, ~= expresses that relationship more narrowly. Avoid describing *= as a general “class wildcard”: it is an attribute-value substring test and can apply to attributes other than class, including data-* attributes.

#1 Best Overall
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

For non-enumerated HTML attributes such as class, string matching is generally case-sensitive. CSS also provides an i modifier for ASCII case-insensitive matching when appropriate, as in [class*="triangle" i].

Which attribute operator matches your intent?

Choose the operator according to the structure you expect in the attribute value, not simply because one selector looks shorter.

Operator What it checks Example intent
= The entire attribute value equals the supplied value. [data-state="open"] selects an exact value.
~= The value contains the supplied value as a whitespace-separated word. [class~="triangle"] selects a complete class token.
|= The value equals the supplied value or begins with it followed by a hyphen. Useful for a language value such as en or en-US.
^= The value begins with the supplied text. [class^="icon-"] checks for a prefix.
$= The value ends with the supplied text. [data-file$=".svg"] checks for a suffix.
*= The value contains the supplied text anywhere. [class*="triangle"] also matches longer class names containing that substring.

These operators are established and widely available in browsers; MDN lists broad browser availability for attribute selectors since July 2015. The key decision is whether the attribute’s actual structure matches the condition the selector expresses.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How to find what made the triangle disappear

  1. Inspect the live element. Open the page’s browser DevTools, select the vanished triangle or its element, and read its current class and other relevant attributes. The live DOM may differ from the original HTML if scripts changed it.
  2. Check matched rules and affected properties. In the Styles or Rules pane, see which selectors match and which declarations are active or crossed out. Check each property involved in the triangle’s implementation; the title does not specify whether it uses borders, dimensions, pseudo-elements, or another technique.
  3. Search for broad attribute selectors. Look for selectors such as [class*=...] and selectors on relevant data-* attributes. Compare the operator with the intended test: exact value, token, prefix, suffix, or arbitrary substring.
  4. Trace the winning declaration. A selector match makes a rule relevant; it does not guarantee that its declaration wins. Inspect the computed value for the property that changed and identify the declaration supplying it.
  5. Make the narrowest correction and verify it. Change the selector to express the intended condition, then confirm the triangle returns and unrelated elements no longer match.

MDN’s Debugging CSS guide notes that a more specific selector can override a change and recommends using DevTools to investigate. That is a useful general diagnostic, not proof that specificity caused this particular failure.

Why a matching rule may not be the winning rule

CSS first determines which rules apply, then resolves competing declarations through the cascade. Origin and importance are considered before specificity; specificity then helps distinguish applicable declarations. If declarations are still tied, other criteria—including scoping proximity and order of appearance—can decide the result.

Class selectors and attribute selectors both contribute to the CLASS column of specificity. But that fact alone does not show that a substring selector overrode the triangle’s styling. The incident details supplied do not identify its declarations, cascade layer or origin, use of !important, scope, or source order. Use the computed style and matched-rule view to establish the actual winner before changing specificity or adding an override.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

What the incident details do—and do not—establish

The stated cause is a selector that matched by substring. The available details do not show the actual selector, markup, browser, triangle technique, affected property, competing declaration, or stylesheet change. Consequently, no specific border fix, pseudo-element adjustment, browser bug, or exact replacement selector can be confirmed. The reliable next step is to compare the live attribute value with the exact selector and trace the winning declaration in DevTools.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.