11

I need to add a custom CSS file to Magento that then is used site-wide. I know you have to add this to a local.xml file, however, the stylesheet I add is just not loaded.

Anyone that can help?

Here is what I've added to my local.xml file:

<?xml version="1.0">
<layout>
    <default>
        <reference name="head">
            <action method="addCss”><type>skin_css</type><file>css/javcustom.css</file></action>
        </reference>
    </default>
</layout>

I know there are a lot of topics on this here, but I've tried all of them and I just can't get it to work...

2 Answers 2

24

There are two way to add css to head one is using function addCss and another is addItem. You have mix-up two format. Your format is wrong.

try this

<action method="addCss">
    <stylesheet>css/javcustom.css</stylesheet>
</action>

instead of

<action method="addCss">
    <type>skin_css</type>
    <file>css/javcustom.css</file>
</action>

or try this

<action method="addItem">
    <type>skin_css</type>
    <name>css/javcustom.css</name>
</action>
4
  • good amit bera. Mar 19, 2015 at 12:48
  • I tried them, but they don't seem to load. When looking at my page source, they just don't show up...
    – dsolivier
    Mar 23, 2015 at 14:16
  • nvm, it worked, there was a typo in what I've typed ;)
    – dsolivier
    Apr 2, 2015 at 8:29
  • 1
    Confirmed, working for me too!
    – camdixon
    Jun 23, 2016 at 23:22
3

To add CSS file follow the below steps:

Open File
app\design\frontend\rwd\default\layout\page.xml
Add the below tag for css:
<action method="addCss"><stylesheet>css/[filename].css</stylesheet></action>

Just below the last method=”addCss” add the above line.
Now open,
skin\frontend\rwd\default\css\[filename].css

Start writing your css code in this file.

To add JS file follow the below steps.

Open File
app\design\frontend\rwd\default\layout\page.xml
Add the below tag
<action method="addItem"><type>skin_js</type><name>js/[filename].js</name></action>

Just below the js include tags similar to the above line.
Now open,
skin\frontend\rwd\default\js\[filename].js

Start writing your js code in this file.

For Magento 2 please refers to this link.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.