function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

static resource in salesforce

hi , i have created a visual force page as and used the stylesheet tag:

<apex:page >

   <apex:stylesheet value="{!URLFOR($Resource.test,'mystyle/style1.css')}"/>
<apex:stylesheet value="{!URLFOR($Resource.test,'style1.css')}"/>
       <link rel="stylesheet"  type="text/css" href="0817F000001YqmZ/style1.css"/>
      <p> this is a 1st  css page</p>
      <h1> this is  Second css </h1>


and create a  css file in notepad and saved as  style1.css .

   color:red ;

and created  a  another css file in notepad and saved as  style2.css .


then after that created a folder name as mystyle and included the two css files and , made as the zip  file  and included into the static resource.

then when calling in the salesforce v.f page the styles are not effecting ?? why?? any error??  

cant we use the css file without including in the static resource???

 is this correct or i should use the anyalternate procedure..
Deepali KulshresthaDeepali Kulshrestha
Hi Vanisree,
I have used this code and it is working fine.

Please Try this code:

<apex:page >
    <apex:stylesheet value="{!URLFOR($Resource.test,'mystyle/style1.css')}"/>
    <apex:stylesheet value="{!URLFOR($Resource.test,'mystyle/style2.css')}"/>
      <p> this is a 1st  css page</p>
      <h1> this is  Second css </h1>

I don't think there is any mistake in your code, the mistake is while saving and making your file zip.
Please follow the similar steps as below:
Step 1: Save your file with extension as .css ie if your file name is test save it as test.css
        For the Save as type Label: choose All types(*.*)
Step 2: To make your file archive:
        Screenshot 1(Save both your files inside a folder, here I'm saving in a folder named "mystyle") 
User-added image
        Screenshot 2(Archive in this way)
        Right click on the folder > send to >compressed (Zipped) folder
          :   User-added image

Step 3: Then save this folderin static resource and follow the code provided above by changing the using the style class names as per your preference. 

Please mark as Best Answer if you found it helpful.
Deepali Kulshrestha