Why does CSS specificity override my fix?

Milestone Fix 100

Why does CSS specificity override my fix?

Understand how the cascade, specificity, source order, inheritance, and real component conflicts work together — so your styles win every time.

100Milestone fix
10Real examples
5Premium patterns
FrontFixer Fix 100 milestone icon
Broken code
.card {
 color: blue;
}
#app .card {
 color: red;
}
/* higher specificity wins */
Your style is losing the cascade.
Correct code
.card {
 color: blue;
}
#app .card {
 color: red;
}
/* Fix: increase specificity */
#app .card--primary {
 color: blue;
}
Now your style wins predictably.
Visual result broken
Orange and black running shoe product card overridden by CSS specificity FIX LOST
Wanted: .card { color: blue; } Winner: #app .card

Premium Runner Pro

The intended blue title is crossed out. A stronger selector still forces the product title to stay red.

Status: Fix overridden
Visual result fixed
Orange and black running shoe product card fixed after CSS specificity correction FIX WINS
Wanted: .card { color: blue; } Winner: .card–primary

Premium Runner Pro

The corrected selector wins in the cascade, so the product title finally follows the intended blue style.

Status: Specificity fixed
Built on best practicesFollow the cascade like a pro.
Fix once, everywhereApply concepts that scale.
Save hours debuggingStop fighting the cascade.
Trusted by real bugsBuilt from front-end pain.
Fast diagnosis

Your CSS is not missing. It is losing.

Specificity override bugs happen when your declaration is part of the page but does not become the used value. That difference matters. If your CSS rule never appears in DevTools, you are probably dealing with cache, loading order, a broken file path, an enqueue problem, or a selector that does not match. But if the rule appears and is crossed out, the browser has already accepted it. The browser is simply choosing another declaration.

The fastest way to debug this is not to add a longer selector. The fastest way is to find the winning rule. Select the element in DevTools. Look at the Styles panel. Find the property you tried to change. Then look for the same property below or above it. The declaration that is not crossed out is the winner. That winner tells you the real cause: stronger selector, later source order, inline style, important declaration, cascade layer, media query, component scope, or shadow DOM boundary.

That is why this fix is the father of the first 99 fixes. Many CSS bugs are not actually property bugs. They are cascade bugs. A button color, card title, pricing highlight, form error state, product badge, mobile spacing rule, or menu active state can all fail for the same hidden reason: the browser is obeying another rule with a stronger cascade position.

Rule missing

If your rule does not appear in DevTools, first check cache, file loading, selector spelling, and whether the CSS is being printed on that page.

Rule crossed out

If the rule is visible but crossed out, the browser loaded it but another declaration won the cascade.

Rule winning

If your rule is winning but the result still looks wrong, the problem may be layout, inheritance, computed values, invalid property use, or a different element.

Related: Test the broken HTML and CSS in the FrontFixer Live Inspector, then inspect selector conflict, source order, inline style, and important escalation before adding heavier code.

The core idea

Specificity is only one part of the cascade.

Developers often say “specificity problem” for every CSS rule that does not apply, but the browser uses more than selector weight. The cascade compares origin, importance, cascade layer, selector specificity, scoping proximity, and source order. In everyday front-end work, the most common fights are selector weight, source order, inline styles, important declarations, and media query order.

Specificity itself is the weight of the selector. An ID selector is heavier than a class selector. A class selector is heavier than an element selector. A selector with multiple classes can beat a single class. A long descendant selector can beat a clean utility class. But specificity is not a moral score. A heavier selector is not automatically better CSS. Heavy selectors can make a site harder to maintain because every future override needs to be heavier again.

The professional solution is to design a cascade path. Base styles should be easy to override. Components should have predictable state classes. Utilities should be intentionally allowed to win. Page-specific fixes should load after shared component CSS. Temporary debug overrides should be removed after the real source is fixed. When the cascade has a system, you do not need to shout with selectors.

Selector weight

A stronger selector can beat your new class even if your new class looks cleaner.

Source order

When specificity is equal, the declaration that appears later usually wins.

Inline style

A style attribute can override normal stylesheet declarations and make a component feel locked.

Layers

A later cascade layer can beat a more specific rule from an earlier layer.

1 · OriginBrowser, user, author, or animation origin enters the contest.
2 · ImportanceNormal and important declarations are separated before weight is compared.
3 · LayerLater cascade layers can beat earlier layers without heavier selectors.
4 · SpecificitySelector pressure decides only after the earlier cascade gates are equal.
5 · ScopeThe nearest scoped rule can matter in modern component systems.
6 · Source orderWhen everything else ties, the later declaration wins quietly.
DevTools workflow

Read the winning rule like a browser detective.

A good specificity fix starts with a very boring action: click the exact element. Do not inspect the parent because it looks close. Do not inspect the visible card if the title inside the card is the element that refuses to change. Specificity bugs often hide one level deeper than expected. A class may be on the wrapper while the color, background, border, padding, or display property lives on a child element. This is especially common with WordPress blocks, product cards, button wrappers, form fields, and navigation menus.

After selecting the exact element, search for the property you tried to fix. If the problem is a title color, search for color. If the problem is a button background, search for background. If the problem is spacing, search for padding or margin. The losing declaration will often be crossed out. The winning declaration will not be crossed out. The file name, line number, and selector beside that declaration are more important than the value itself because they tell you where the rule came from.

Once you find the winner, ask why it won. Did it win because the selector has more classes? Did it win because it appears lower in the file? Did it come from a later stylesheet? Did it come from a media query that only exists at this screen size? Did a page builder write the value directly into the HTML with style=""? Did a plugin add !important? Each answer points to a different kind of fix. A selector weight problem may need a scoped selector. A source order problem may need the override to load later. An inline style problem may need the source setting removed. An important problem may need the important declaration cleaned at the source.

This workflow protects you from the most expensive mistake in CSS debugging: changing the wrong rule. Many developers see a crossed-out declaration and immediately paste a stronger selector at the bottom of the page. It works for ten minutes, then breaks a second component. The professional move is slower for the first thirty seconds and faster for the rest of the project. You identify the real source, decide whether the original rule is too heavy, and choose an override that belongs to the component system.

Step 1

Select the exact element, not the closest wrapper. The wrapper may not own the property that is failing.

Step 2

Find the property that refuses to change and compare the crossed-out declaration with the winning one.

Step 3

Fix the reason the winner wins instead of adding random selector weight.

<article class=”product-card”>
  <h3 class=”product-title”>
  <p class=”description”>
</article>
.product-title { color:#2563eb; }
crossed out · fix is loaded but losing
.shop-card .content h3.product-title { color:#b42318; }
winning declaration · inspect file and selector source
Next action: repair ownership or source order instead of pasting a longer revenge selector.
Specificity mental model

Do not memorize numbers. Understand pressure.

Specificity is often explained with number groups: inline styles, IDs, classes, attributes, pseudo-classes, elements, and pseudo-elements. That model is useful, but in daily work the more practical idea is pressure. Every selector applies pressure to win a property. IDs apply heavy pressure. Classes and attributes apply medium pressure. Elements apply light pressure. Source order applies pressure when the selector weight is equal. Cascade layers can change the contest before specificity even gets compared.

This is why a selector like .card-title can lose to .product-card .content h3.card-title. The second selector is not smarter. It simply applies more pressure. It names the product card, the content wrapper, the element, and the title class. If you respond with body .page .shop .grid .product-card .content h3.card-title, you may win, but you also create a future problem. The next person must now beat your selector, and the stylesheet begins to grow like a chain of revenge.

A better mental model is ownership. Ask which part of the system should own the visual decision. Should the button component own its base color? Should the hero section own a special hero button? Should a utility class be allowed to override text color anywhere? Should a sale state override a neutral badge? Should a WordPress block inherit the global button style, or should the page define a special milestone button? Once you know ownership, specificity becomes a tool instead of a fight.

Low-specificity systems are easier to maintain because they keep ownership clear. The base component uses one class. Variants use one additional class or data attribute. Utilities load in a known place. Page-specific overrides stay inside a page wrapper. Emergency CSS stays temporary. That kind of discipline feels less dramatic than a giant selector, but it is the difference between a site that grows and a site that slowly becomes untouchable.

ID pressure

Powerful and usually too heavy for normal component styling.

Class pressure

Ideal for components, states, utilities, and page-level wrappers.

Element pressure

Light by itself, but risky when chained through many descendants.

Order pressure

The quiet winner when two selectors are equally specific.

ElementLight pressure. Good for broad defaults.
Class / attributeComponent-friendly pressure. Usually the maintainable center.
Multiple classesUseful when scope and state belong together.
ID / inlineHeavy pressure. Expensive to override later.
WordPress and real projects

Specificity bugs are louder on WordPress because many systems write CSS at the same time.

On a hand-coded static page, you often know where every rule came from. On a WordPress site, the cascade may include the theme stylesheet, block library CSS, plugin CSS, customizer CSS, page builder CSS, snippet CSS, cached/minified CSS, and content-specific HTML. That does not make WordPress bad. It just means the cascade has more authors. A rule can be technically correct and still lose because it is entering a crowded room.

The common WordPress mistake is placing a small custom rule in a random snippet and expecting it to beat everything. Sometimes it will. Sometimes it will not. A block button may have a generated class. A plugin form may print field styles after your theme. A page builder may write inline styles. A cache plugin may serve an older combined file. A theme may use long selectors to style navigation and content areas. If you do not know the order, you cannot trust the outcome.

That is why milestone pages should have their own wrapper class and their own scoped CSS. The wrapper tells the browser and the developer, “this visual system belongs to this page.” Instead of writing global selectors like .card, .button, or section, the milestone CSS should write selectors such as .ffx-fix100 .ffx100-example and .ffx-fix100 .ffx100-btn. This gives the page a premium visual identity without contaminating older fixes, archives, the homepage, or the Live Inspector.

Page-specific CSS is not a shortcut when it is scoped correctly. It is a safety boundary. A normal fix article can use the standard FrontFixer layout. A milestone fix can use a more cinematic structure. The difference is acceptable because the milestone wrapper prevents the premium style from leaking into every post. The site can have a special event page without turning the global CSS into a dangerous shared bomb.

Production rule: if a CSS snippet is meant for one page, every selector should start with the page wrapper. For this milestone, that wrapper is .ffx-fix100. No loose .card. No loose .btn. No loose h2. No loose section.

1
Theme defaultsTypography, buttons, content widths, navigation.
shared base
2
Block libraryGenerated Gutenberg classes and block-level styles.
editor layer
3
Plugin CSSForms, commerce, tables, widgets, embeds.
third party
4
Custom component CSSFrontFixer reusable components and standard fixes.
owned system
5
Fix 100 milestone scope.ffx-fix100 protects the cinematic page without contaminating the site.
page winner
When it is not specificity

Do not blame specificity for every CSS failure.

Specificity is powerful, but it is not the answer to every CSS problem. If the declaration does not appear in DevTools, the issue is usually not specificity. The CSS may not be loading. The cache may be serving an older file. The selector may not match the generated HTML. The class may be misspelled. The property may be invalid. The value may be invalid. The element may be inside an iframe or shadow DOM. The browser may support the property differently than expected. A parent layout rule may be controlling the visual result.

For example, if z-index does not work, the problem may be stacking context, not specificity. If margin seems ignored in a flex or grid layout, the problem may be alignment or available space. If a transition does not animate, the problem may be that the property is not animatable or the starting value is missing. If a class does not apply, the problem may be that the class is on the wrong element. If a width does not shrink on mobile, the problem may be an image, table, or long word causing overflow.

This matters because the wrong diagnosis creates worse CSS. If the real problem is invalid HTML and you respond with heavier selectors, the page becomes harder to debug and still may not be correct. If the real problem is cache and you respond with !important, you create a future override problem for no reason. If the real problem is media query order and you edit only the desktop rule, the bug will keep coming back on phones.

The clean question is simple: can I see my declaration in DevTools, and is it crossed out? If yes, investigate the cascade. If no, investigate loading, matching, validity, and structure first. This one question separates specificity bugs from everything else.

Not visible

Debug loading, cache, selector match, or whether the code is printed on this page.

Visible and crossed out

Debug specificity, order, layers, inline styles, important, or responsive context.

Visible and winning

Debug layout, inheritance, computed values, wrong element, unsupported behavior, or another property.

Rule missingNot a specificity fight yet

Check file loading, cache, selector match, invalid CSS, iframe boundaries, and whether the code is printed on this page.

Rule crossed outCascade conflict confirmed

Compare importance, layer, specificity, scope, media-query context, inline style, and source order.

Rule winningLook beyond the cascade

Inspect layout, inheritance, computed values, wrong element targeting, unsupported behavior, and competing properties.

Visual proof rule

Same asset. Same layout. One CSS decision changed.

A trustworthy broken-versus-fixed demonstration does not swap the product, crop, or composition. It keeps the evidence stable so the reader can see exactly which cascade decision changed the interface.

Same real imageThe subject never changes between the broken and fixed states.
Same component shellCard dimensions, copy, hierarchy, and placement stay consistent.
One visible CSS differenceColor, state, spacing, border, or selector ownership is the only proof that changes.
Same FrontFixer running shoe with the losing CSS stateFIX LOST

Premium Runner Pro

The product stays identical. Only the title state proves the selector lost.

Same FrontFixer running shoe with the corrected CSS stateFIX WINS

Premium Runner Pro

Same asset, same card, same copy. The corrected cascade is the only variable.

10 real-world pain examples

Broken code, corrected code, and real visual impact.

Each example below recreates a normal front-end pain with a complete interface, the losing rule, the corrected rule, and a visible product consequence. The subject and layout stay consistent between the broken and fixed sides so the reader can isolate the cascade change immediately.

Example 01

Product card title color refuses to change

A developer adds a clean class to make a product title blue, but the title stays red because the shop card selector is more specific.

Selector weight
Broken CSS
.product-title {
 color: #2563eb;
}
.shop-card .content h3.product-title {
 color: #b42318;
}
Broken visual resultRed wins
Example 01 real visual — broken CSS stateFIX LOST
Winning selector: .shop-card .content h3.product-titlePremium Runner ProSame shoe, same card, same content.
RED WINSThe title stays red because the heavier shop selector still owns the property.
The new class is valid, but the old selector has more weight because it includes the parent card, content wrapper, element, and class.
Correct CSS
.shop-card .product-title {
 color: #2563eb;
}
/* Better long-term:
   reduce the original selector
   and style the component with classes. */
Fixed visual resultBlue wins
Example 01 real visual — corrected CSS stateFIX WINS
Winning selector: .shop-card .product-titlePremium Runner ProSame shoe, same card, same content.
BLUE WINSThe title is blue because the component-scoped selector now owns the property.
The fix matches the component scope. The selector is strong enough to win but still understandable for the next developer.
Example 02

CTA button keeps the old theme color

This happens constantly in themes and landing pages. The custom button class is simple, but the hero button rule is loaded with component context.

Theme selector
Broken CSS
.cta-button {
 background: #ff5a16;
}
.hero .hero-actions .button.cta-button {
 background: #111827;
}
Broken visual resultTheme wins
Example 02 real visual — broken CSS stateFIX LOST
Build faster. Debug with confidence.Real landing-page hero using the same laptop image.Start fixing
THEME WINSThe theme keeps the CTA dark, so the main action disappears into the hero.
Adding the class is not enough when the theme uses a more specific component selector.
Correct CSS
.hero .cta-button {
 background: #ff5a16;
}
/* Or load this override after the hero component file
   if the selector weight is already equal. */
Fixed visual resultCTA fixed
Example 02 real visual — corrected CSS stateFIX WINS
Build faster. Debug with confidence.Real landing-page hero using the same laptop image.Start fixing
CTA RESTOREDThe orange CTA matches the product identity and becomes the obvious next action.
Use the smallest selector that matches the real component context and wins predictably.
Example 03

Sale badge style is ignored

A badge should look urgent, but the generic badge system wins because the sale class is only a single class and the component rule is stronger.

State class losing
Broken CSS
.is-sale {
 background: #ef4444;
 color: white;
}
.product-card .badge {
 background: #f3f4f6;
 color: #111827;
}
Broken visual resultBadge too quiet
Example 03 real visual — broken CSS stateFIX LOSTSALE
50%
OFF
Studio Headset · $89
BADGE TOO QUIETThe badge is technically present, but the generic gray component style hides urgency.
The state class exists, but the component badge selector wins the visual decision.
Correct CSS
.product-card .badge.is-sale {
 background: #ef4444;
 color: white;
}
/* Component + state is clear:
   this is a badge, and this badge is on sale. */
Fixed visual resultState wins
Example 03 real visual — corrected CSS stateFIX WINSSALE
50%
OFF
Studio Headset · $89
SALE STATE WINSThe sale state is unmistakable and visually earns attention.
Component plus state is usually safer than a disconnected state class floating alone.
Example 04

WordPress button block ignores your custom CSS

WordPress blocks often ship with their own class names. If your custom class is too weak or loads too early, the block style may win.

WordPress block
Broken CSS
.orange-link {
 background: #ff5a16;
}
.wp-block-button .wp-block-button__link {
 background: #111827;
}
Broken visual resultBlock wins
Example 04 real visual — broken CSS stateFIX LOST
WButton block previewwp-block-button__link winsLearn more
BLOCK CSS WINSThe WordPress block style keeps its default blue button despite the custom class.
The block selector uses two WordPress classes. A single custom class may lose unless it is loaded later or scoped correctly.
Correct CSS
.wp-block-button .wp-block-button__link.orange-link {
 background: #ff5a16;
}
/* Alternative:
   add a wrapper class to the block group
   and target the button inside that group. */
Fixed visual resultCustom block wins
Example 04 real visual — corrected CSS stateFIX WINS
WButton block previewPage scope wins over block CSSLearn more
BLOCK FIXEDThe page-scoped block selector restores the FrontFixer orange action.
In WordPress, inspect the exact generated HTML. The class you added may be on a wrapper, not the element that needs the style.
Example 05

Navigation active link color does not apply

The active menu item should stand out, but a header navigation selector beats the state class. The result is a menu where the current page does not look current.

Navigation state
Broken CSS
.active {
 color: #ff5a16;
}
.site-header nav ul li a {
 color: #111827;
}
Broken visual resultCurrent page hidden
Example 05 real visual — broken CSS stateFIX LOST
HomeFixesPatternsTools
ACTIVE STATE LOSTThe active link blends into the dark navigation because the theme selector wins.
A generic state class can lose to a long navigation selector with multiple elements.
Correct CSS
.site-header nav a.active {
 color: #ff5a16;
}
/* Better:
   use .nav-link and .nav-link--active
   instead of relying on element chains. */
Fixed visual resultActive state visible
Example 05 real visual — corrected CSS stateFIX WINS
HomeFixesPatternsTools
ACTIVE STATE VISIBLEThe active route is orange and underlined, so orientation is immediate.
The fixed selector keeps the state attached to the navigation link without matching every nested element in the header.
Example 06

Form error message will not turn red

Form plugins and design systems often style inputs and messages aggressively. A simple error class can lose to field-specific selectors.

Plugin CSS
Broken CSS
.error-message {
 color: #ef4444;
}
.contact-form .field .message {
 color: #667085;
}
Broken visual resultError looks normal
Example 06 real visual — broken CSS stateFIX LOST
john@example
Error message is present but visually muted.
DEFAULT FIELD WINSThe message exists, but the component default keeps the field visually neutral.
The visual meaning fails because the plugin or component message selector is stronger than the error class.
Correct CSS
.contact-form .message.error-message {
 color: #ef4444;
}
.contact-form .field.is-invalid .message {
 color: #ef4444;
}
Fixed visual resultError state wins
Example 06 real visual — corrected CSS stateFIX WINS
john@example
Please enter a valid email address.
ERROR STATE WINSThe input, helper text, and error meaning now share one explicit state.
A parent invalid state is often cleaner because the input, label, and message can all respond to one class.
Example 07

Pricing card highlight does not work

A “Popular” pricing card should look different, but the base pricing card style wins because the highlight class is not scoped to the component.

Component variant
Broken CSS
.featured {
 border-color: #ff5a16;
 transform: translateY(-6px);
}
.pricing-grid .pricing-card {
 border-color: #e5e7eb;
 transform: none;
}
Broken visual resultNo highlight
Example 07 real visual — broken CSS stateFIX LOST
HIGHLIGHT LOSTAll three plans look equal because the generic pricing-card rule defeats the featured state.
The variant class is too generic. It loses to the pricing component’s base card rule.
Correct CSS
.pricing-card.featured {
 border-color: #ff5a16;
 transform: translateY(-6px);
}
/* The variant belongs to the card,
   not to the entire page as a generic class. */
Fixed visual resultVariant visible
Example 07 real visual — corrected CSS stateFIX WINS
PLAN HIGHLIGHTEDThe center plan gains the intended orange border, elevation, and hierarchy.
Attach the variant to the component class so the CSS explains what is changing and where.
Example 08

Mobile spacing fix works on desktop but loses on mobile

This one feels like a ghost bug. The desktop fix works, but a later media query redefines the same property on smaller screens.

Media query order
Broken CSS
.product-card {
 padding: 18px;
}
@media (max-width: 640px) {
 .product-card {
 padding: 32px;
 }
}
Broken visual resultMobile still bloated
Example 08 real visual — broken CSS stateFIX LOST
32PX OVERRIDEThe desktop selector remains heavier, so the phone keeps oversized padding.
The mobile media query appears later and redefines the same property, so it wins on mobile.
Correct CSS
.product-card {
 padding: 18px;
}
@media (max-width: 640px) {
 .product-card {
 padding: 18px;
 }
}
Fixed visual resultMobile matches fix
Example 08 real visual — corrected CSS stateFIX WINS
18PX MOBILEThe mobile rule now owns the mobile context and restores usable breathing room.
When a bug only happens at one breakpoint, inspect the winning rule while DevTools is set to that breakpoint.
Example 09

Utility class loses to component CSS

Utility classes are supposed to be quick and predictable. But if component CSS has heavier selectors and loads after utilities, the utility class becomes unreliable.

Utility conflict
Broken CSS
.text-blue {
 color: #2563eb;
}
.article-card .card-title {
 color: #111827;
}
Broken visual resultUtility ignored
Example 09 real visual — broken CSS stateFIX LOST
.article-card .title winsBuild cleaner visual systemsSame camera, same editorial card, different cascade owner.
COMPONENT WINSThe reusable utility is loaded, but the component title rule still owns the color.
A utility system only works if utilities are intentionally allowed to override component defaults.
Correct CSS
/* Components first */
.article-card .card-title {
 color: #111827;
}
/* Utilities later */
.text-blue {
 color: #2563eb;
}
Fixed visual resultUtility wins
Example 09 real visual — corrected CSS stateFIX WINS
.text-blue winsBuild cleaner visual systemsSame camera, same editorial card, different cascade owner.
UTILITY WINSThe utility class is intentionally allowed to win, so the editorial title becomes blue.
Do not mix utility-first expectations with component-last source order unless you have a clear exception system.
Example 10

Inline style from a builder blocks the fix

Page builders, JavaScript widgets, and marketing tools sometimes inject inline styles. A normal stylesheet rule will usually lose to a style attribute.

Inline style
Broken HTML/CSS
.promo-title {
 color: #2563eb;
}
<h2 class="promo-title" style="color:#b42318">
 Summer Promo
</h2>
Broken visual resultInline wins
Example 10 real visual — broken CSS stateFIX LOST
Theme CSS lowComponent CSS mediumInline style wins
Buy now
INLINE LOCKThe inline builder value has the highest normal specificity and locks the button purple.
This is not a normal selector fight. The style attribute has a stronger cascade position than normal stylesheet rules.
Correct HTML/CSS
<h2 class="promo-title promo-title--summer">
 Summer Promo
</h2>
.promo-title--summer {
 color: #2563eb;
}
Fixed visual resultCSS controls it
Example 10 real visual — corrected CSS stateFIX WINS
Theme CSS lowComponent CSS mediumInline style removed
Buy now
CSS CONTROL RESTOREDThe builder setting is removed or normalized, returning color control to the component CSS.
If the inline style comes from a tool setting, fix the setting first. Only use an important override as a temporary last resort.
5 premium result patterns

Better CSS systems avoid selector wars.

The examples above show how CSS breaks in real pages. The patterns below show how to stop the same kind of problem from returning. These are not decorative tricks. They are production habits: low specificity components, cascade layers, design tokens, state attributes, and a WordPress override map.

Pattern 01

Low-specificity component pattern

Use simple component classes and keep the base selector easy to override. The :where() selector is useful because it can group context without adding specificity.

Premium CSS
:where(.shop-section) .product-card {
 border: 1px solid #e5e7eb;
}
.product-card--featured {
 border-color: #ff5a16;
}
Premium pattern 01FrontFixer Fix 100 premium pattern 01
A real product component demonstrates how low-specificity classes remain reusable and easy to override.
Pattern 02

Cascade layer pattern

Layers make the override path explicit. A utility layer can be designed to beat component defaults without needing huge selectors.

Premium CSS
@layer reset, base, components, utilities;
@layer components {
 .card-title { color: #111827; }
}
@layer utilities {
 .text-blue { color: #2563eb; }
}
Premium pattern 02FrontFixer Fix 100 premium pattern 02
The layer inspector makes source order explicit and shows which cascade layer has permission to win.
Pattern 03

Design token override pattern

Instead of fighting the same property in multiple selectors, expose the visual decision as a custom property. The component reads the token, and variants change the token.

Premium CSS
.product-card {
 --title-color: #111827;
}
.product-card__title {
 color: var(--title-color);
}
.product-card--sale {
 --title-color: #b42318;
}
Premium pattern 03FrontFixer Fix 100 premium pattern 03
A visual token manager connects colors, typography, spacing, and component output to one maintainable system.
Pattern 04

State attribute pattern

Data attributes make states readable and predictable. This is useful when a component has modes like active, disabled, sale, featured, open, loading, or error.

Premium CSS
.card[data-state="featured"] {
 border-color: #ff5a16;
}
.form-field[data-state="error"] .message {
 color: #ef4444;
}
Premium pattern 04FrontFixer Fix 100 premium pattern 04
One component is shown across default, featured, loading, disabled, and error states without selector escalation.
Pattern 05

WordPress override map pattern

In WordPress, the cleanest solution is often not heavier CSS. It is knowing where each layer comes from: theme, block, plugin, custom snippet, page CSS, and temporary debug CSS.

Override order
1. Theme defaults
2. Block styles
3. Plugin styles
4. Custom component CSS
5. Page-specific milestone CSS
6. Temporary debug overrides
Premium pattern 05FrontFixer Fix 100 premium pattern 05
The WordPress map exposes theme, block, plugin, component, and page-scope CSS as an auditable override chain.
Bonus discipline

Important is an escape hatch, not a workflow

!important can be correct in rare utility systems or emergency overrides, but using it as the first response turns every future change into a fight. Before using it, ask why the normal cascade cannot win.

Better question
/* Not first: */
.button { color: orange !important; }
/* First ask:
   Which declaration is winning,
   and why does it have permission to win? */
Professional checklist

How to debug a specificity override without guessing.

Use this checklist when a CSS fix looks correct but the page refuses to change. The goal is to identify the winning declaration before writing the next line of CSS. This prevents selector escalation, random important declarations, and changes that fix one page while breaking another.

  • Inspect the exact element that should receive the style.
  • Confirm that your CSS rule appears in DevTools.
  • If the rule is missing, debug loading before specificity.
  • If the rule is crossed out, find the declaration that wins.
  • Compare selector specificity, not only class names.
  • Check whether the winning rule appears later in the stylesheet.
  • Check the same property inside media queries.
  • Look for inline styles generated by builders, scripts, or plugins.
  • Look for !important before adding another one.
  • Check whether cascade layers are changing the winner.
  • Reduce the original heavy selector when you control the CSS.
  • Scope overrides to the component, not the whole page.
  • Prefer state classes or data attributes over random long selectors.
  • Use custom properties when variants only change values.
  • Keep temporary debug CSS separate and remove it later.
  • Document page-specific override rules on large projects.
Common mistakes

What not to do when specificity overrides your fix.

Do not add IDs just to win

An ID may fix the current page, but it raises the weight of the system and makes future overrides harder.

Do not paste !important everywhere

Important can become a trap. If every fix needs important, the cascade is no longer designed.

Do not debug in the wrong breakpoint

If the bug appears only on mobile, inspect the element while the viewport is actually mobile.

Do not style wrappers by accident

Many WordPress and builder elements put your class on a wrapper while the visual style lives on a child.

Do not trust the class name alone

A class can exist and still lose. The final winner is decided by the cascade, not by your intention.

Do not leave debug CSS forever

Temporary overrides should be removed or converted into a clean component rule after the bug is understood.

Final boss challenge

Fix this without using !important.

You have a product card. The title should be blue only when the card is featured. The badge should be orange only when the card is on sale. The mobile padding should stay compact. The theme currently overrides all three. Your challenge is to fix the cascade path, not to shout louder.

FrontFixer Cascade LabFinal Boss · no !important

Challenge CSS — three losing decisions

.featured { color: #2563eb; }
.is-sale { background: #ff5a16; }
.product-card { padding: 18px; }
.shop .grid .product-card h3 {
 color: #111827;
}
.shop .product-card .badge {
 background: #f3f4f6;
}
@media (max-width: 640px) {
 .product-card {
 padding: 32px;
 }
}

Clean solution — match scope, state, and media context

.shop .product-card.featured h3 {
 color: #2563eb;
}
.shop .product-card .badge.is-sale {
 background: #ff5a16;
 color: white;
}
@media (max-width: 640px) {
 .shop .product-card {
 padding: 18px;
 }
}
Component scope matchedThe fix competes at the same meaningful boundary as the winning theme rule.
State stays inside the componentFeatured and sale styles describe the actual product-card state.
Mobile rule wins on mobileThe compact padding is declared inside the same responsive context.

The solution is not magic. It targets the same component scope as the winning rules, fixes the state inside the component, and handles the mobile rule inside the mobile context. No important declaration is needed because the cascade path is now clear.

Final takeaway

The browser is not ignoring you. The cascade is answering first.

When CSS specificity overrides your fix, the correct response is not panic. The correct response is inspection. Find the winning declaration, understand why it wins, and then choose the smallest clean change that gives your rule permission to win. That may be selector scope, source order, a state class, a custom property, a cascade layer, or removing inline styling from the source.

Fix 100 matters because specificity is not just one bug. It is the invisible engine behind many CSS bugs. Once you can read the cascade, you stop treating CSS like a guessing game and start treating it like a system.

Why Is My CSS Class Not Applying?

CSS class not applying problems usually happen when the class name does not match, the selector is written wrong, the stylesheet is not loading, or another CSS rule overrides the class.

CSS Debugging Fix

Why is my CSS class not applying?

You add a class to an element, write the CSS, refresh the page, and nothing changes. This is one of the most annoying front-end bugs because the code can look correct at a glance. Most of the time, the class is not applying because of a typo, missing dot, wrong selector, stylesheet loading issue, CSS specificity conflict, or a build/cache problem.

  • Class selector bugs
  • Specificity conflicts
  • Stylesheet loading
  • DevTools debugging

What the bug looks like

You add a class and write CSS for it, but the element keeps the old design, spacing, color, or layout.

Why it happens

The class selector is either not matching, not loading, not winning, or not attached to the element you think it is.

What usually fixes it

Match the class name exactly, use the correct selector, inspect the loaded CSS, and check whether the rule is crossed out.

Error 1

The class name in HTML and CSS does not match

This is the fastest mistake to make and the easiest to miss. CSS class names must match exactly. A missing hyphen or different spelling means the selector never reaches the element.

Broken code

Class mismatch
<div class="hero-card">
  Premium layout
</div>

.herocard {
  background: #fff5ef;
  border-color: #ffd2c2;
}

Broken visual result

Selector misses
Premium layout

The HTML has hero-card, but the CSS targets .herocard.

Unstyled CTA
The browser cannot apply a class rule that does not match the real class name.

Correct code

Class names match
<div class="hero-card">
  Premium layout
</div>

.hero-card {
  background: #fff5ef;
  border-color: #ffd2c2;
}

Fixed visual result

Selector matches
Premium layout

The CSS selector now matches the class used in the HTML.

Styled CTA
Once the class name matches exactly, the rule can reach the element.
Error 2

The selector is missing the class dot

In CSS, a class selector needs a dot. Without it, the browser looks for an HTML element with that name instead of a class. This can make a perfectly good class appear ignored.

Broken code

Missing dot
<button class="cta-button">
  Start fixing
</button>

cta-button {
  background: #ff6a3d;
  color: white;
}

Broken visual result

Browser looks for an element
HTML class: cta-button real
CSS selector: cta-button wrong type
Without the dot, the selector is not targeting a class.

Correct code

Class selector
<button class="cta-button">
  Start fixing
</button>

.cta-button {
  background: #ff6a3d;
  color: white;
}

Fixed visual result

Class selector works
HTML class: cta-button real
CSS selector: .cta-button matches
The dot tells CSS to target elements with that class.
Error 3

The class applies, but a stronger rule overrides it

Sometimes your class is applying, but you still do not see the expected style because another selector wins. In DevTools, your rule may appear crossed out.

Broken code

Specificity conflict
.card {
  background: #fff5ef;
}

.page .content .card {
  background: white;
}

Broken visual result

Class rule crossed out
.card background: #fff5ef overridden
.page .content .card background: white wins
The class exists, but a stronger selector controls the final style.

Correct code

Target intentionally
.content .card {
  background: white;
}

.content .card.is-featured {
  background: #fff5ef;
  border-color: #ffd2c2;
}

Fixed visual result

Intentional selector wins
.content .card base style base
.content .card.is-featured wins
The modifier class is now written to win clearly without random !important.
Error 4

The stylesheet with the class rule is not loading

Your class and selector can both be perfect, but nothing will happen if the CSS file is not loaded on the page. This is common with wrong file paths, stale cache, minified files, or build output that was not regenerated.

Broken code

Missing stylesheet
<link rel="stylesheet" href="/css/layout.css">

/* But the class lives in: */
components/card.css

.card-feature {
  border-color: #ffd2c2;
}

Broken visual result

Rule never loads
/css/layout.css loaded
components/card.css missing
The browser cannot apply CSS from a file it never downloaded.

Correct code

Load the right file
<link rel="stylesheet" href="/css/layout.css">
<link rel="stylesheet" href="/css/components/card.css">

.card-feature {
  border-color: #ffd2c2;
}

Fixed visual result

Rule is available
/css/layout.css loaded
/css/components/card.css loaded
Once the stylesheet loads, the class rule becomes available to the page.
Premium pattern

A production-minded CSS class pattern

A stronger class system keeps names consistent, uses readable modifiers, avoids random specificity battles, and makes component states clear.

Premium code

Clear component classes
<article class="pricing-card pricing-card--featured">
  <h2 class="pricing-card__title">Pro Plan</h2>
  <a class="pricing-card__button" href="#">Start now</a>
</article>

.pricing-card {
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  background: white;
}

.pricing-card--featured {
  border-color: #ffd2c2;
  box-shadow: 0 18px 38px rgba(255,106,61,.12);
}

.pricing-card__button {
  background: #ff6a3d;
  color: white;
}

Premium visual result

Classes describe the component
Pro Plan

The class names are consistent, readable, and connected to the component they style.

Start now
Premium class naming makes debugging easier because the HTML and CSS tell the same story.

Fast practical rule

If a CSS class is not applying, inspect the element in DevTools. First confirm the class exists in the HTML. Then confirm the selector appears in the Styles panel. If it appears crossed out, you have a specificity or order problem. If it does not appear, you have a selector, file, or cache problem.

Debug checklist

  • Check the HTML class name and CSS selector spelling character by character.
  • Make sure class selectors start with a dot, like .card.
  • Inspect the element and confirm the class is really present in the DOM.
  • Check whether your CSS rule appears in DevTools.
  • If the rule is crossed out, check specificity and CSS order.
  • If the rule does not appear, check whether the stylesheet is loaded.
  • Clear cache or rebuild assets if you recently changed the CSS file.
  • Avoid using !important until you know why the class is losing.
Best first move Inspect the element and confirm whether the class exists in the rendered DOM.
Most common cause A tiny mismatch between the HTML class name and the CSS selector.
Most misleading cause The class is applying, but a stronger selector overrides it.
Better mindset A class not applying is not a guessing game. DevTools can show whether the problem is matching, loading, or winning.

Final takeaway

A CSS class not applying usually means one of three things: the selector does not match, the stylesheet is not loading, or another rule is winning. Once you identify which one it is, the fix becomes simple.

Start in DevTools. Confirm the class exists, confirm the rule appears, and confirm whether it is active or crossed out. That gives you a real answer instead of turning the stylesheet into a pile of random overrides.

Want more fixes like this?

Browse more CSS debugging guides or jump to the full FrontFixer library.

Why Is My Hover Effect Not Working?

A hover effect usually stops working when the selector does not match the element, another layer is blocking the pointer, a stronger CSS rule overrides the hover state, or the device does not actually support hover.

CSS Interaction Fix

Why is my hover effect not working?

A hover effect can fail in several sneaky ways. The button may not change color, the card may not lift, the dropdown may not open, or the effect may work on desktop but feel broken on mobile. The problem is usually not “hover is broken.” The real issue is selector targeting, CSS order, specificity, pointer events, overlays, disabled elements, or touch-screen behavior.

  • Hover selector bugs
  • Pointer events
  • CSS specificity
  • Touch devices

What the bug looks like

The button does not change color, the card does not lift, the menu does not open, or the hover works only when your mouse is over a tiny part of the element.

Why it happens

The hover rule is either not matching, not winning, not receiving pointer input, or being tested on a device where hover does not behave normally.

What usually fixes it

Confirm the selector, inspect the active rule, remove blocking layers, add transitions to the base state, and design a touch-friendly fallback.

Error 1

The hover selector targets the wrong element

This is the simplest hover bug. The CSS is valid, but the selector does not match the element you are actually hovering. The browser is doing exactly what you asked. It is just not the element you meant.

Broken code

Wrong selector
<a class="cta-button" href="#">
  Start fixing
</a>

.button:hover {
  background: #ff6a3d;
  color: white;
}

Broken visual result

Hover rule never matches
CTA area The button class is cta-button, but the CSS is targeting .button:hover. Start fixing
The hover effect looks broken because the selector and the HTML class do not match.

Correct code

Matching selector
<a class="cta-button" href="#">
  Start fixing
</a>

.cta-button:hover {
  background: #ff6a3d;
  color: white;
}

Fixed visual result

Hover rule matches
CTA area The selector now targets the same class that exists in the HTML. Start fixing
The effect appears because the hover rule is attached to the correct element.
Error 2

A later CSS rule overrides the hover effect

Sometimes the hover selector is correct, but it still loses. The hover state may be crossed out in DevTools because a later rule or stronger selector keeps the old color, transform, or opacity.

Broken code

Hover loses cascade
.card:hover {
  transform: translateY(-4px);
  background: #fff5ef;
}

.featured-card {
  transform: none;
  background: white;
}

Broken visual result

Hover is overridden
.card:hover transform: translateY(-4px) overridden
.featured-card transform: none wins
The hover rule exists, but another rule wins the final computed style.

Correct code

Hover wins intentionally
.featured-card {
  background: white;
  transition: transform .2s ease, background .2s ease;
}

.featured-card:hover {
  transform: translateY(-4px);
  background: #fff5ef;
}

Fixed visual result

Hover wins
.featured-card base style base
.featured-card:hover transform active
The hover state now targets the same component and appears after the base style.
Error 3

An invisible overlay blocks the hover target

This is a sneaky one. An absolutely positioned layer, pseudo-element, or overlay can sit above the button. Your mouse is technically hovering the overlay, not the button underneath.

Broken code

Overlay steals pointer
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
}

.card .button {
  position: relative;
  z-index: 1;
}

Broken visual result

Pointer hits overlay
Card content The button looks visible, but another layer is sitting above it. Hover me
Invisible overlay blocks hover
The hover target is visually there, but it is not receiving the pointer.

Correct code

Overlay ignores pointer
.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.card .button {
  position: relative;
  z-index: 2;
}

Fixed visual result

Button receives hover
Card content The decorative layer is still there, but it no longer steals pointer input. Hover me
Overlay no longer blocks
Use pointer-events:none only on decorative layers that should not be interactive.
Error 4

The hover effect is being tested on a touch device

Mobile devices do not have a mouse cursor hovering above the screen. Some browsers simulate hover after a tap, some do not, and some leave hover-like states stuck. A hover-only interaction is not a safe mobile pattern.

Broken code

Hover-only UI
.menu {
  display: none;
}

.nav:hover .menu {
  display: block;
}

Broken visual result

Touch has no real hover
Mobile menu The menu depends only on hover, so it may not open reliably on phones. Menu
Hover can be a nice desktop enhancement, but it should not be the only way to reveal important content.

Correct code

Hover plus focus
.menu {
  display: none;
}

.nav:hover .menu,
.nav:focus-within .menu {
  display: block;
}

.nav-toggle {
  cursor: pointer;
}

Fixed visual result

Keyboard and tap friendlier
Mobile menu The interaction now supports hover and focus, making it less fragile. Menu
For serious mobile navigation, JavaScript state is often more reliable than hover-only behavior.
Premium pattern

A production-minded hover pattern

The stronger pattern treats hover as progressive enhancement. The base state works. The focus state works. Touch users are not blocked. Motion is smooth, but not required for the interface to make sense.

Premium code

Hover, focus, motion-safe
.card {
  position: relative;
  border: 1px solid #e5e7eb;
  border-radius: 24px;
  background: #fff;
  transition:
    transform .2s ease,
    border-color .2s ease,
    box-shadow .2s ease;
}

.card:hover,
.card:focus-within {
  transform: translateY(-3px);
  border-color: #ffd2c2;
  box-shadow: 0 18px 38px rgba(255,106,61,.12);
}

.card::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

@media (hover: none) {
  .card:hover {
    transform: none;
  }
}

Premium visual result

Hover is enhancement
Production-ready card

The component has a good base state, a hover state, a focus state, and a safer touch-device fallback.

Open fix
Premium hover is not just pretty. It is predictable, accessible, and less likely to break across devices.

Fast practical rule

If a hover effect is not working, inspect the element and force the :hover state in DevTools. If the rule appears but is crossed out, fix specificity or order. If the rule never appears, fix the selector. If the element never receives hover, check overlays and pointer events.

Debug checklist

  • Confirm the hover selector matches the actual class or element in the HTML.
  • Use DevTools to force :hover and see whether the rule becomes active.
  • Check whether the hover rule is crossed out by a later or stronger selector.
  • Check whether an overlay, pseudo-element, or absolute layer is sitting above the target.
  • Use pointer-events:none only on decorative layers that should not receive input.
  • Make sure transitions are placed on the base element, not only on the hover state.
  • Do not rely on hover-only behavior for important mobile interactions.
  • Add :focus or :focus-within when the element should also work by keyboard or tap.
Best first move Force :hover in DevTools before changing random CSS.
Most common cause The selector does not match the element you are actually hovering.
Most invisible cause An overlay or pseudo-element is sitting above the button and stealing the pointer.
Better mindset Hover should improve the interface, not be the only way the interface works.

Final takeaway

A hover effect not working usually has a concrete cause: the selector is wrong, the rule is overridden, the element is not receiving pointer input, or the device does not support hover the way a desktop mouse does.

Start by forcing :hover in DevTools. Then check whether the rule matches, whether it wins, and whether another layer is blocking the target. Once those three questions are answered, the fix becomes much easier.

Want more fixes like this?

Browse more CSS interaction and layout debugging guides in the FrontFixer library.

Why Is My CSS Not Updating After I Change It?

CSS not updating after you change it usually means the browser is still reading an old file, a different stylesheet, or a stronger CSS rule than the one you just edited.

CSS Debugging Fix

Why is my CSS not updating after I change it?

You change the CSS, save the file, refresh the page, and nothing happens. The button keeps the old color. The card still has the old spacing. The mobile layout still looks broken. In most real projects, the problem is not that CSS is ignoring you. The problem is usually cache, file order, specificity, the wrong stylesheet, minified assets, or a build process that has not generated the new file yet.

  • CSS cache
  • Wrong stylesheet
  • Specificity conflicts
  • WordPress debugging

What the bug looks like

You change a color, margin, font size, layout rule, or mobile style, but the visible page keeps showing the old design.

Why it happens

The page is either loading old CSS, loading a different CSS file, or applying a stronger rule after your new rule.

What usually fixes it

Hard refresh, clear cache, confirm the loaded file in DevTools, inspect the rule, then fix specificity, order, or the build pipeline.

Error 1

The browser is still loading the cached stylesheet

This is the classic reason CSS changes do not show. You saved the file, but the browser already has an older version stored. So the code is changed on the server, while your screen still shows yesterday’s CSS.

Broken code

Old cached file
<link rel="stylesheet" href="/assets/style.css">

/* You changed this today */
.hero-card {
  border-radius: 24px;
  background: white;
}

Broken visual result

Old CSS still visible
Old header style
Old card shape The page still looks like the previous version because the cached file is being used.
The CSS file was changed, but the browser did not request a fresh copy.

Correct code

Cache-busted file
<link rel="stylesheet"
      href="/assets/style.css?v=2026-06-06">

/* New version now reaches the browser */
.hero-card {
  border-radius: 24px;
  background: white;
}

Fixed visual result

Fresh CSS loaded
Updated header style
New card shape The browser now loads the newer file, so the visual update finally appears.
Versioning the file URL forces the browser to request the updated stylesheet.
Error 2

A stronger selector overrides the CSS you changed

Sometimes the CSS is updating, but your rule is losing. In DevTools, the new property may appear crossed out because a more specific selector, inline style, or later rule is winning the cascade.

Broken code

Weak selector loses
.button {
  background: #ff6a3d;
}

/* Later or stronger rule */
.header .button {
  background: #0f172a;
}

Broken visual result

New rule crossed out
.button background: #ff6a3d overridden
.header .button background: #0f172a wins
The file updated, but the rule you edited is not the rule controlling the final button style.

Correct code

Target the real selector
.header .button {
  background: #ff6a3d;
}

.header .button:hover {
  background: #eb5628;
}

Fixed visual result

Correct rule wins
.header .button background: #ff6a3d active
.header .button:hover background: #eb5628 ready
The update works because the rule now matches the selector that actually controls the element.
Error 3

You edited a file the page is not loading

This one feels ridiculous until it happens. The CSS file you edited may not be the CSS file loaded by the page. WordPress themes, child themes, page builders, minified assets, and build tools can all create this confusion.

Broken code

Wrong file edited
/* You edited this file */
themes/frontfixer/style.css

.card {
  padding: 28px;
}

/* But the page actually loads */
uploads/cache/minified-style.css

Broken visual result

Wrong source file
themes/frontfixer/style.css edited
uploads/cache/minified-style.css loaded
Your code changed, but not in the file that the browser is currently using.

Correct code

Confirm loaded source
/* In DevTools, check the rule source */
.card {
  padding: 28px;
}

/* Then edit the real source or purge/rebuild */
Loaded file:
style.css?ver=2026-06-06

Fixed visual result

Right file confirmed
style.css?ver=2026-06-06 loaded
.card padding: 28px active
DevTools tells you the exact stylesheet and line where the winning rule is coming from.
Error 4

WordPress cache or optimization is serving old CSS

In WordPress, your CSS may be correct but still not visible because an optimization plugin, server cache, CDN cache, or minified file is serving an older generated version. This is common after editing Custom CSS, theme files, or page-level HTML/CSS.

Broken setup

Old optimized CSS
Original CSS changed:
.card {
  border-radius: 24px;
}

/* But the front-end still loads */
combined.min.css
cached by plugin/CDN/server

Broken visual result

Optimized file is stale
Cached version
Old minified CSS The page is still using a generated file that has not been refreshed.
Clearing only the browser cache may not be enough if the server or plugin is serving old CSS.

Correct workflow

Purge and rebuild
After editing CSS:

1. Save the post/theme/CSS file
2. Purge plugin cache
3. Purge server/CDN cache if used
4. Regenerate/minify CSS if needed
5. Hard refresh the browser

Fixed visual result

Fresh optimized CSS
Updated version
New generated file The optimized CSS has been rebuilt, so the live page finally matches your edit.
For WordPress sites, always think in layers: browser cache, plugin cache, server cache, CDN cache.
Premium pattern

A production-minded CSS update workflow

The stronger fix is not just refreshing harder. A reliable workflow makes CSS updates predictable: version your stylesheet, inspect the winning rule, avoid random specificity wars, and use a clear cache purge routine after important changes.

Premium workflow

Predictable updates
<link rel="stylesheet"
      href="/assets/style.css?v=2026-06-06">

/* Keep selectors intentional */
.ffx-card {
  padding: clamp(18px, 3vw, 28px);
  border-radius: 24px;
}

/* Avoid random emergency overrides */
.ffx-card.is-featured {
  border-color: #ffd2c2;
  box-shadow: 0 18px 38px rgba(255,106,61,.12);
}

/* After deploying:
   hard refresh, inspect source,
   purge cache, then request indexing
   for important updated pages. */

Premium visual result

Clean update path
Production-ready CSS
Predictable visual update The stylesheet is versioned, the selector is intentional, and the cache workflow is clear.
The premium version does not rely on panic-refreshing. It makes the CSS pipeline easier to trust.

Fast practical rule

If CSS is not updating, do not immediately add !important. First check whether the browser is loading the new file at all. Then inspect the exact rule in DevTools. If the file is old, fix cache. If the rule is crossed out, fix specificity or order.

Debug checklist

  • Hard refresh the page with the browser cache bypassed.
  • Open DevTools and confirm the stylesheet URL actually changed or loaded fresh.
  • Inspect the element and check whether your rule is active or crossed out.
  • Confirm you edited the stylesheet that the page is really loading.
  • Check whether a later rule overrides your new rule.
  • Check selector specificity before using !important.
  • Clear WordPress plugin cache, server cache, CDN cache, and minified CSS when relevant.
  • If your project uses a build process, rebuild the compiled CSS file.
  • Test in an incognito window or another browser to separate browser cache from server cache.
Best first move Inspect the element in DevTools and check whether your new rule appears at all.
Most common cause Browser, plugin, CDN, or server cache is still serving an older CSS file.
Most misleading cause The CSS changed, but another selector is stronger, so the visual result stays the same.
Better mindset CSS debugging is not guessing. It is proving which file loaded and which rule won.

Final takeaway

CSS not updating is usually not a mystery. The page is either loading an old stylesheet, loading a different stylesheet, or applying a different rule than the one you edited. Once you separate those three possibilities, the bug becomes much easier to fix.

Start with DevTools. Confirm the file. Confirm the selector. Confirm the winning rule. Then clear or rebuild the cache only where needed. That is faster than stacking random overrides until the stylesheet becomes harder to maintain.

Want more fixes like this?

Browse more CSS debugging guides or jump to the full FrontFixer library.

Why Is My Media Query Not Working?

Media query not working problems usually happen when the browser is reading a different viewport, a different CSS rule, or a more rigid layout than the one you think you are testing.

Responsive CSS Fix

Why is my media query not working?

If your mobile styles are not applying, your breakpoint seems ignored, or your layout stays stuck in desktop mode, the browser is usually not being random. The real issue is usually a missing viewport tag, invalid syntax, CSS order, specificity, cache, or a rigid layout that makes the media query look broken even when it is actually firing.

  • Viewport setup
  • Breakpoint logic
  • CSS cascade
  • Rigid layout traps

What the bug looks like

Your CSS says mobile should be one column, but the page stays in desktop mode. Or your media query changes one thing, but the layout still overflows and looks broken.

Why it happens

A media query does not magically make a layout responsive. It only applies CSS under a condition. If setup, cascade, or structure is wrong, the result still breaks.

What usually fixes it

Confirm the viewport tag, test the breakpoint in DevTools, inspect overridden rules, then replace rigid layout rules with flexible responsive patterns.

Error 1

Missing viewport tag makes mobile CSS look ignored

This is one of the most common reasons a media query does not work on mobile. Without the viewport meta tag, the browser may render the page as a wide desktop canvas and scale it down. Your breakpoint may not match the real screen the way you expect.

Broken code

Missing viewport
<head>
  <title>My Page</title>
  <link rel="stylesheet" href="style.css">
</head>

@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

Broken visual result

Mobile acts like desktop
Card 1
Card 2
Card 3
The page is still behaving like a wide desktop canvas, so the mobile layout feels ignored.

Correct code

Real mobile viewport
<head>
  <meta name="viewport"
        content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="style.css">
</head>

@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

Fixed visual result

Viewport matches device
Card 1
Card 2
Card 3
The browser now treats the screen as a real mobile viewport, so the breakpoint can behave correctly.
Error 2

Invalid media query syntax silently breaks the rule

Media query syntax is easy to almost get right. A missing space, missing unit, wrong parenthesis, or forgotten brace can make the browser skip the rule or read it differently than you intended.

Broken code

Syntax trap
@media screen and(max-width: 768px) {
  .menu {
    display: none;
  }

  .cards {
    grid-template-columns: 1fr;
  }
}

Broken visual result

Breakpoint ignored
Desktop nav still visible
Card
Card
Card
The CSS looks close, but the condition is malformed, so the mobile rule does not behave as expected.

Correct code

Valid condition
@media screen and (max-width: 768px) {
  .menu {
    display: none;
  }

  .cards {
    grid-template-columns: 1fr;
  }
}

Fixed visual result

Mobile rule applies
Compact mobile header
Card 1
Card 2
Card 3
The same layout now stacks because the media query condition is valid and readable.
Error 3

The media query works, but CSS order overrides it

The browser may be applying your media query correctly, then immediately replacing it with a later rule. This is why media queries can “work” in DevTools but still not change what you see on the page.

Broken code

Later desktop rule wins
@media (max-width: 768px) {
  .card-title {
    font-size: 18px;
  }
}

.card-title {
  font-size: 36px;
}

Broken visual result

Mobile rule crossed out

Huge title on mobile

The media query fires, but the later desktop rule wins the cascade.

@media font-size: 18pxoverridden
later font-size: 36pxwins

Correct code

Mobile rule comes after
.card-title {
  font-size: 36px;
}

@media (max-width: 768px) {
  .card-title {
    font-size: 22px;
  }
}

Fixed visual result

Mobile rule wins

Readable mobile title

The mobile rule appears later, so the cascade now matches the responsive intention.

base font-size: 36pxbase
@media font-size: 22pxwins
Error 4

The breakpoint fires, but the layout is still rigid

This is the grown-up version of the media query bug. The media query is not dead. The layout is still too rigid. A fixed-width wrapper, a wide grid, a long code block, or an image without responsive limits can make the page look broken even after the breakpoint activates.

Broken code

Breakpoint fires, layout still breaks
.wrapper {
  width: 1200px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, 320px);
}

@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

Broken visual result

The wrapper is still 1200px
Mobile breakpoint active
Wide wrapper
Still overflowing
Not responsive
The media query changed the grid, but the parent still forces a desktop width.

Correct code

Flexible parent and grid
.wrapper {
  width: min(100%, 1200px);
  margin-inline: auto;
  padding-inline: 16px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 24px;
}

@media (max-width: 768px) {
  .cards {
    grid-template-columns: 1fr;
  }
}

Fixed visual result

Parent can shrink
Responsive layout
Card 1
Card 2
Card 3
Now the wrapper and grid both cooperate with the breakpoint.
Premium pattern

A production-minded media query setup

The best responsive fix is not just one media query. It is a layout system that starts flexible, uses safe grid tracks, lets children shrink, protects images, and only uses breakpoints to adjust behavior—not to rescue broken desktop code.

Premium code

Flexible first
.layout {
  width: min(100%, 1120px);
  margin-inline: auto;
  padding-inline: clamp(16px, 4vw, 32px);
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: clamp(16px, 3vw, 28px);
}

.card,
.card * {
  min-width: 0;
}

.card img {
  display: block;
  max-width: 100%;
  height: auto;
}

@media (max-width: 768px) {
  .layout {
    padding-inline: 16px;
  }

  .card-title {
    font-size: clamp(24px, 8vw, 34px);
  }
}

Premium visual result

Flexible before breakpoint
Production-ready cards
Safe card width
No overflow trap
Breakpoint becomes lighter
The layout is responsive even before the media query has to do heavy work.

Fast practical rule

If your media query is not working, do not start by changing random breakpoint numbers. First confirm the viewport tag, then test whether the rule is firing in DevTools, then check whether another rule or a rigid parent is still winning.

Debug checklist

  • Confirm the page includes <meta name="viewport" content="width=device-width, initial-scale=1">.
  • Resize the page in DevTools and confirm whether the media query is actually firing.
  • Check the media query syntax for missing spaces, braces, parentheses, units, and invalid conditions.
  • Inspect whether a later CSS rule is overriding the media query.
  • Check whether a stronger selector is beating your mobile selector.
  • Verify whether the breakpoint should use max-width or min-width.
  • Look for a fixed-width wrapper, wide grid track, long word, code block, image, table, or child element that refuses to shrink.
  • Clear browser, plugin, and CDN cache if your CSS changes are not showing at all.
Best first move Use DevTools to see whether the media query is active before changing the breakpoint value.
Most overlooked cause The viewport tag is missing, so the browser never behaves like the real mobile screen.
Most frustrating cause The media query works, but a later CSS rule silently overrides it.
Better mindset Media queries should tune a flexible layout, not save a layout that was built rigid from the beginning.

Final takeaway

A media query not working rarely means the browser is broken. Most of the time, the browser is following the rules exactly: the viewport is wrong, the condition is invalid, the cascade is overriding the rule, specificity is too strong, cache is stale, or the layout is still too rigid to respond.

Start by proving whether the media query is active. Then debug the cascade. Then fix the structure. Once the layout is flexible first, media queries become precise adjustments instead of emergency rescue patches.

Want more fixes like this?

Browse more responsive debugging guides or jump to the full FrontFixer library.