---
title: "tinymce.html.Schema"
description: "Schema validator class."
canonical_url: "https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.html.schema/"
md_url: "https://www.tiny.cloud/docs/tinymce/latest/apis/tinymce.html.schema/index.md"
version: "latest"
last_updated: "2025-10-23T01:37:47Z"
tokens: 2420
---
# tinymce.html.Schema

Schema validator class.

## Examples

```javascript
if (tinymce.activeEditor.schema.isValidChild('p', 'span')) {
  alert('span is valid child of p.');
}

if (tinymce.activeEditor.schema.getElementRule('p')) {
  alert('P is a valid element.');
}
```

## Summary

### Methods

| Name | Summary | Defined by |
| --- | --- | --- |
| [addCustomElements()](#addCustomElements) | Adds custom non-HTML elements to the schema. For more information about adding custom elements see: [custom_elements](/docs/tinymce/latest/content-filtering/#custom_elements) | `Schema` |
| [addValidChildren()](#addValidChildren) | Parses a valid children string and adds them to the schema structure. The valid children format is for example `element[child1\|child2]`. | `Schema` |
| [addValidElements()](#addValidElements) | Parses a valid elements string and adds it to the schema. The valid elements format is for example `element[attr=default\|otherattr]`. Existing rules will be replaced with the ones specified, so this extends the schema. | `Schema` |
| [getBlockElements()](#getBlockElements) | Returns a map with block elements. | `Schema` |
| [getBoolAttrs()](#getBoolAttrs) | Returns a map with boolean attributes. | `Schema` |
| [getComponentUrls()](#getComponentUrls) | Returns an object of all custom elements that have component URLs. | `Schema` |
| [getCustomElements()](#getCustomElements) | Returns an map object of all custom elements. | `Schema` |
| [getElementRule()](#getElementRule) | Returns true/false if the specified element is valid or not according to the schema. | `Schema` |
| [getInvalidStyles()](#getInvalidStyles) | Name/value map object with valid styles for each element. | `Schema` |
| [getMoveCaretBeforeOnEnterElements()](#getMoveCaretBeforeOnEnterElements) | Returns a map with elements that the caret should be moved in front of after enter is pressed. | `Schema` |
| [getNonEmptyElements()](#getNonEmptyElements) | Returns a map with elements that should be treated as contents regardless if it has text content in them or not. For example: `<td>`, `<video>` or `<img>`. | `Schema` |
| [getSelfClosingElements()](#getSelfClosingElements) | Returns a map with self closing tags. For example: `<li>`. | `Schema` |
| [getSpecialElements()](#getSpecialElements) | Returns a map with special elements. These are elements that needs to be parsed in a special way such as script, style, textarea etc. The map object values are regexps used to find the end of the element. | `Schema` |
| [getTextBlockElements()](#getTextBlockElements) | Returns a map with text block elements. For example: `<p>`, `<h1>` to `<h6>`, `<div>` or `<address>`. | `Schema` |
| [getTextInlineElements()](#getTextInlineElements) | Returns a map of inline text format nodes. For example: `<strong>`, `<span>` or `<ins>`. | `Schema` |
| [getTransparentElements()](#getTransparentElements) | Returns a map with elements that should be treated as transparent. | `Schema` |
| [getValidClasses()](#getValidClasses) | Name/value map object with valid classes for each element. | `Schema` |
| [getValidStyles()](#getValidStyles) | Name/value map object with valid styles for each element. | `Schema` |
| [getVoidElements()](#getVoidElements) | Returns a map with void elements. For example: `<br>` or `<img>`. | `Schema` |
| [getWhitespaceElements()](#getWhitespaceElements) | Returns a map with elements where white space is to be preserved. For example: `<pre>` or `<script>`. | `Schema` |
| [isValid()](#isValid) | Returns true/false if the specified element name and optional attribute is valid according to the schema. | `Schema` |
| [isValidChild()](#isValidChild) | Returns true/false if the specified element and it’s child is valid or not according to the schema. | `Schema` |
| [setValidElements()](#setValidElements) | Parses a valid elements string and sets it to the schema. The valid elements format is for example `element[attr=default\|otherattr]`. Existing rules will be replaced with the ones specified, so this extends the schema. | `Schema` |

## Methods

### addCustomElements()

```javascript
addCustomElements(custom_elements: String | Object)
```
Adds custom non-HTML elements to the schema. For more information about adding custom elements see: [custom_elements](/docs/tinymce/latest/content-filtering/#custom_elements)

#### Parameters

- `custom_elements (String | Object)` - Comma separated list or record of custom elements to add.

### addValidChildren()

```javascript
addValidChildren(valid_children: String)
```
Parses a valid children string and adds them to the schema structure. The valid children
format is for example `element[child1|child2]`.

#### Parameters

- `valid_children (String)` - Valid children elements string to parse

### addValidElements()

```javascript
addValidElements(valid_elements: String)
```
Parses a valid elements string and adds it to the schema. The valid elements
format is for example `element[attr=default|otherattr]`.
Existing rules will be replaced with the ones specified, so this extends the schema.

#### Parameters

- `valid_elements (String)` - String in the valid elements format to be parsed.

### getBlockElements()

```javascript
getBlockElements(): Object
```
Returns a map with block elements.

#### Return value

- `Object` - Name/value lookup map for block elements.

### getBoolAttrs()

```javascript
getBoolAttrs(): Object
```
Returns a map with boolean attributes.

#### Return value

- `Object` - Name/value lookup map for boolean attributes.

### getComponentUrls()

```javascript
getComponentUrls(): Object
```
Returns an object of all custom elements that have component URLs.

#### Return value

- `Object` - Object with where key is the component and the value is the url for that component.

### getCustomElements()

```javascript
getCustomElements(): Object
```
Returns an map object of all custom elements.

#### Return value

- `Object` - Name/value map object of all custom elements.

### getElementRule()

```javascript
getElementRule(name: String): Object
```
Returns true/false if the specified element is valid or not
according to the schema.

#### Parameters

- `name (String)` - Element name to check for.

#### Return value

- `Object` - Element object or undefined if the element isn’t valid.

### getInvalidStyles()

```javascript
getInvalidStyles()
```
Name/value map object with valid styles for each element.

### getMoveCaretBeforeOnEnterElements()

```javascript
getMoveCaretBeforeOnEnterElements(): Object
```
Returns a map with elements that the caret should be moved in front of after enter is
pressed.

#### Return value

- `Object` - Name/value lookup map for elements to place the caret in front of.

### getNonEmptyElements()

```javascript
getNonEmptyElements(): Object
```
Returns a map with elements that should be treated as contents regardless if it has text
content in them or not. For example: `<td>`, `<video>` or `<img>`.

#### Return value

- `Object` - Name/value lookup map for non empty elements.

### getSelfClosingElements()

```javascript
getSelfClosingElements(): Object
```
Returns a map with self closing tags. For example: `<li>`.

#### Return value

- `Object` - Name/value lookup map for self closing tags elements.

### getSpecialElements()

```javascript
getSpecialElements(): Object
```
Returns a map with special elements. These are elements that needs to be parsed
in a special way such as script, style, textarea etc. The map object values
are regexps used to find the end of the element.

#### Return value

- `Object` - Name/value lookup map for special elements.

### getTextBlockElements()

```javascript
getTextBlockElements(): Object
```
Returns a map with text block elements. For example: `<p>`, `<h1>` to `<h6>`, `<div>` or `<address>`.

#### Return value

- `Object` - Name/value lookup map for block elements.

### getTextInlineElements()

```javascript
getTextInlineElements(): Object
```
Returns a map of inline text format nodes. For example: `<strong>`, `<span>` or `<ins>`.

#### Return value

- `Object` - Name/value lookup map for text format elements.

### getTransparentElements()

```javascript
getTransparentElements(): Object
```
Returns a map with elements that should be treated as transparent.

#### Return value

- `Object` - Name/value lookup map for special elements.

### getValidClasses()

```javascript
getValidClasses()
```
Name/value map object with valid classes for each element.

### getValidStyles()

```javascript
getValidStyles()
```
Name/value map object with valid styles for each element.

### getVoidElements()

```javascript
getVoidElements(): Object
```
Returns a map with void elements. For example: `<br>` or `<img>`.

#### Return value

- `Object` - Name/value lookup map for void elements.

### getWhitespaceElements()

```javascript
getWhitespaceElements(): Object
```
Returns a map with elements where white space is to be preserved. For example: `<pre>` or `<script>`.

#### Return value

- `Object` - Name/value lookup map for white space elements.

### isValid()

```javascript
isValid(name: String, attr: String): Boolean
```
Returns true/false if the specified element name and optional attribute is
valid according to the schema.

#### Parameters

- `name (String)` - Name of element to check.
- `attr (String)` - Optional attribute name to check for.

#### Return value

- `Boolean` - True/false if the element and attribute is valid.

### isValidChild()

```javascript
isValidChild(name: String, child: String): Boolean
```
Returns true/false if the specified element and it’s child is valid or not
according to the schema.

#### Parameters

- `name (String)` - Element name to check for.
- `child (String)` - Element child to verify.

#### Return value

- `Boolean` - True/false if the element is a valid child of the specified parent.

### setValidElements()

```javascript
setValidElements(valid_elements: String)
```
Parses a valid elements string and sets it to the schema. The valid elements
format is for example `element[attr=default|otherattr]`.
Existing rules will be replaced with the ones specified, so this extends the schema.

#### Parameters

- `valid_elements (String)` - String in the valid elements format to be parsed.
