---
schema_version: "1"
id: af99f3b63ca88e870157ec0d24939dcf315d341100e9c735eecd0379d764bb26
title: $Resource
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/variables/pages-variables-global-resource.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-variables-global-resource.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: c1371fff5a118fea5d2a2c13c5cfc9f94d172118da4b1f0752a8c738e416017d
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# $Resource

A global merge field type to use when referencing an existing static resource by name in a Visualforce page. You can also use resource merge fields in `URLFOR` functions to reference a particular file in a static resource archive.

## Usage

Use `{!$Resource}` to reference an existing static resource. The format is `{!$Resource.nameOfResource}`, such as `{!$Resource.TestImage}`.

## Examples

The Visualforce component below references an image file that was uploaded as a static resource and given the name `TestImage`:

```visualforce
<apex:image url="{!$Resource.TestImage}" width="50" height="50"/>
```

To reference a file in an archive (such as a .zip or .jar file), use the `URLFOR` function. Specify the static resource name that you provided when you uploaded the archive with the first parameter, and the path to the desired file within the archive with the second. For example:

```visualforce
<apex:image url="{!URLFOR($Resource.TestZip,
                  'images/Bluehills.jpg')}" width="50" height="50"/>
```

You can also use dynamic references to reference static resources. For example, `{!$Resource[appLogo]}`, assuming there is an `appLogo` property or `getAppLogo()` method in your page’s controller.

**See Also**  


-   [Styling Visualforce Pages](https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/styling/pages-styling.md)

