I start building new theme from scratch and I add
when i test new css with simple code website not working correctly
Add css to
Deploy static content
You need to add default_head_block.xl file in your custom theme in Magento_Theme directory.
Add your custom css file to app/design/frontend/namespace/theme/web/css/custom.css
and copy this code
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <css src="css/custom.css" /> </head> </page>
After adding this, delete your pub/static/frontend/ directory and deploy static files.
The file that you are using needs to be
default.head.blocks.xml. This file can live in a lot of places, but i prefer to have it here:
Make sure the css file is should up in the
pub/static/frontend folder structure. The css might be in different places inside those fodlers depending on your set up, so i can say the exact path. But it needs to be in there for the browser to see it. This is easy to check as the browser will give you a 404 on the file if the xml is set up correctly.
Double check the syntax of your file. It should look something like this:
<?xml version="1.0"?> <page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd"> <head> <!-- Google Fonts --> <!-- <link src="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800" src_type="url" rel="stylesheet" /> --> <css src="css/styles-m.css" /> </head> </page>
And inside that file, you need to make sure that your xml is valid, i can't count how many times i missed a closing tag that made the file invalid. Test it here: