<!--
{
  "documentType" : "article",
  "framework" : "TVML",
  "identifier" : "/documentation/TVML/divtemplate",
  "metadataVersion" : "0.1.0",
  "role" : "collectionGroup",
  "title" : "divTemplate"
}
-->

# divTemplate

Provides the ability to create pages that don’t conform to a layout defined by another
template.

## Overview

There is no built-in layout for contained elements. The `divTemplate` element creates
a view where the elements it contains are arranged using the `tv-align` and `tv-position`
styles. Containing elements are centered by default. The following figure shows the
positions inside of the `divTemplate` element. The `divTemplate` element should only
be used when you can’t use another template to achieve the look you want. The theme
for the div template defaults to the system preference.

![Layout diagram showing the positions other elements can be placed in.](images/com.apple.TVML/divtemplate-1.png)

Elements contained in the same position are arranged from the top of the cell to
the bottom, in the same order in which they are specified in the `divTemplate` element.
You can specify a `<background><img /></background>` that displays a background image
inside of the `divTemplate`. The background image is top-aligned and is fitted to
the size of the `divTemplate` while keeping the image’s original aspect ratio. Text
wrapping inside of the `divTemplate` only occurs in the `header`, `center`, and `footer`
positions.

## Topics

### Valid TVML Styles

[tv-align](/documentation/TVML/tv-align)

Aligns an element horizontally inside its parent.

[tv-position](/documentation/TVML/tv-position)

Sets the position of an element inside of its parent element.

### Valid TVML Attributes

[binding](/documentation/TVML/binding)

Associates information in a data item with an element.

[layoutDirection](/documentation/TVML/layoutdirection)

Specifies the direction in which text is displayed.

[prototype](/documentation/TVML/prototype)

Associates a data item type with an element.

[theme](/documentation/TVML/theme)

Sets the color scheme for an element.



---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)