---
schema_version: "1"
id: 8d38bd18f8bf5e60204007865d87683d393d72be3ba502739de67ae3a4367c4b
title: apex:define
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/platform/salesforce-pages-developers-guide/guides/pages/components/pages-compref-define.md
canonical_url: https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-compref-define.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: d121e820996d53f2377e13fec31599396b9bcc584590cbc6f286d447ed4dd2ae
products:
  - Visualforce Developer Guide
  - Platform Developer Content
---

# apex:define

A template component that provides content for an `<apex:insert>` component defined in a Visualforce template page.

Use this component to get user input for a controller method that does not correspond to a field on an sObject. Only `<apex:inputField>` and `<apex:outputField>` can be used with sObject fields.

See also: `<apex:composition>`, `<apex:insert>`

## Example

```apex
<!-- Page: composition -->
<!-- This page acts as the template. Create it first, then the page below.  -->	
<apex:page>
    <apex:outputText value="(template) This is before the header"/><br/>
    <apex:insert name="header"/><br/>
    <apex:outputText value="(template) This is between the header and body"/><br/>
    <apex:insert name="body"/>
</apex:page>
            
<!-- Page: page -->
<apex:page>
    <apex:composition template="composition">
        <apex:define name="header">(page) This is the header of mypage</apex:define>
        <apex:define name="body">(page) This is the body of mypage</apex:define>
    </apex:composition>
</apex:page>
```

The example above renders the following HTML:

```html
(template) This is before the header<br/>
(page) This is the header of mypage<br/>
(template) This is between the header and body<br/>
(page) This is the body of mypage
```

## Attributes

|Attribute Name|Attribute Type|Description|Required?|API Version|Access|
|--------------|--------------|-----------|---------|-----------|------|
|`name`|String|The name of the insert component into which the content of this define component should be inserted.|Yes|10.0|global|

**See Also**  


-   [apex:composition](https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-compref-composition.md)
-   [apex:insert](https://developer.salesforce.com/docs/platform/salesforce-pages-developers-guide/guide/pages-compref-insert.md)

