PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, August 22, 2022

[FIXED] Why are my styles not applying after a custom CSS file is included?

 August 22, 2022     css, html, magento2, xml     No comments   

Issue

I am using Magento 2.2.3. In my magneto theme added custom CSS file in the below path: project/app/design/frontend/vendor/theme/web/css/custom.css

I added source file in default_head_blocks.XML file. after that added a page with following code in HTML content

<div class="freegotest"><span class="tested">count down custom code</span></div>

In custom.css code as

.tested { 
    color: red !important; 
    font-size: 20px;
}

By viewing the page source, I can see the custom CSS file included in the header, but the styles are not applying to the text.


Solution

Your XML file must be named default_head_blocks.xml instead of default_head_blocks.XML.

Once the name changed, clear cache and static files :

  1. Check if you are using dev mode With command line
php bin/magento deploy:mode:show
  1. If developer mode is set to production, try to re-build static content
php bin/magento setup:static-content:deploy
  1. In any cases (production or developer), clear every cached files
php bin/magento setup:upgrade
php bin/magento setup:di:compile
php bin/magento cache:flush;


Answered By - Antoine Martin
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing