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

# rules

Contains the elements used in data binding and media queries.

## Overview

The `rules` element contains a set of `specialize` elements that are used to modify
existing elements. The `specialize` elements use data queries to determine how the
existing element is modified. Here’s an example that sets the rules for a `button`
element.

```xml
<rules>
    <specialize state="({progress}-greater-than:0) and ({progress}-less-than:1)">
        <button tag="button">
            <text>Resume</text>
        </button>
    </specialize>
    <specialize state="({progress}:0), ({progress}:1)">
        <button tag="button">
            <text>Play</text>
        </button>
    </specialize>
</rules>
```

### Subelements of rules

- [specialize](/documentation/TVML/specialize)

### Elements that Use rules

The `rules` element can used by any other element.

## Topics

### Valid TVML Attributes

[binding](/documentation/TVML/binding)

Associates information in a data item with an element.

[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)