Element

A generic element. `https://developers.google.com/apps-script/reference/document/document` contents are
represented as elements. For example, `https://developers.google.com/apps-script/reference/document/list-item`, `https://developers.google.com/apps-script/reference/document/paragraph`, and `https://developers.google.com/apps-script/reference/document/table` are
elements and inherit all of the methods defined by `Element`, such as `https://developers.google.com/apps-script/reference/document/element#getType()`.

### Implementing classes

| Name | Brief description |
|---|---|
| `https://developers.google.com/apps-script/reference/document/body` | The content of a tab in a Google Docs document. |
| `https://developers.google.com/apps-script/reference/document/container-element` | A generic element that may contain other elements. |
| `https://developers.google.com/apps-script/reference/document/date` | An element representing a formatted date |
| `https://developers.google.com/apps-script/reference/document/equation` | An element representing a mathematical expression. |
| `https://developers.google.com/apps-script/reference/document/equation-function` | An element representing a function in a mathematical `https://developers.google.com/apps-script/reference/document/equation`. |
| `https://developers.google.com/apps-script/reference/document/equation-function-argument-separator` | An element representing a function separator in a mathematical `https://developers.google.com/apps-script/reference/document/equation`. |
| `https://developers.google.com/apps-script/reference/document/equation-symbol` | An element representing a symbol in a mathematical `https://developers.google.com/apps-script/reference/document/equation`. |
| `https://developers.google.com/apps-script/reference/document/footer-section` | An element representing a footer section. |
| `https://developers.google.com/apps-script/reference/document/footnote` | An element representing a footnote. |
| `https://developers.google.com/apps-script/reference/document/footnote-section` | An element representing a footnote section. |
| `https://developers.google.com/apps-script/reference/document/header-section` | An element representing a header section. |
| `https://developers.google.com/apps-script/reference/document/horizontal-rule` | An element representing an horizontal rule. |
| `https://developers.google.com/apps-script/reference/document/inline-drawing` | An element representing an embedded drawing. |
| `https://developers.google.com/apps-script/reference/document/inline-image` | An element representing an embedded image. |
| `https://developers.google.com/apps-script/reference/document/list-item` | An element representing a list item. |
| `https://developers.google.com/apps-script/reference/document/page-break` | An element representing a page break. |
| `https://developers.google.com/apps-script/reference/document/paragraph` | An element representing a paragraph. |
| `https://developers.google.com/apps-script/reference/document/person` | An element representing a link to a person. |
| `https://developers.google.com/apps-script/reference/document/rich-link` | An element representing a link to a Google resource, such as a Drive file or a YouTube video. |
| `https://developers.google.com/apps-script/reference/document/table` | An element representing a table. |
| `https://developers.google.com/apps-script/reference/document/table-cell` | An element representing a table cell. |
| `https://developers.google.com/apps-script/reference/document/table-of-contents` | An element containing a table of contents. |
| `https://developers.google.com/apps-script/reference/document/table-row` | An element representing a table row. |
| `https://developers.google.com/apps-script/reference/document/text` | An element representing a rich text region. |
| `https://developers.google.com/apps-script/reference/document/unsupported-element` | An element representing a region that is unknown or cannot be affected by a script, such as a page number. |

### Methods

| Method | Return type | Brief description |
|---|---|---|
| `https://developers.google.com/apps-script/reference/document/element#asBody()` | `https://developers.google.com/apps-script/reference/document/body` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/body`. |
| `https://developers.google.com/apps-script/reference/document/element#asDate()` | `https://developers.google.com/apps-script/reference/document/date` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/date`. |
| `https://developers.google.com/apps-script/reference/document/element#asEquation()` | `https://developers.google.com/apps-script/reference/document/equation` | Returns the current element as an `https://developers.google.com/apps-script/reference/document/equation`. |
| `https://developers.google.com/apps-script/reference/document/element#asEquationFunction()` | `https://developers.google.com/apps-script/reference/document/equation-function` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/equation-function`. |
| `https://developers.google.com/apps-script/reference/document/element#asEquationFunctionArgumentSeparator()` | `https://developers.google.com/apps-script/reference/document/equation-function-argument-separator` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/equation-function-argument-separator`. |
| `https://developers.google.com/apps-script/reference/document/element#asEquationSymbol()` | `https://developers.google.com/apps-script/reference/document/equation-symbol` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/equation-symbol`. |
| `https://developers.google.com/apps-script/reference/document/element#asFooterSection()` | `https://developers.google.com/apps-script/reference/document/footer-section` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/footer-section`. |
| `https://developers.google.com/apps-script/reference/document/element#asFootnote()` | `https://developers.google.com/apps-script/reference/document/footnote` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/footnote`. |
| `https://developers.google.com/apps-script/reference/document/element#asFootnoteSection()` | `https://developers.google.com/apps-script/reference/document/footnote-section` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/footnote-section`. |
| `https://developers.google.com/apps-script/reference/document/element#asHeaderSection()` | `https://developers.google.com/apps-script/reference/document/header-section` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/header-section`. |
| `https://developers.google.com/apps-script/reference/document/element#asHorizontalRule()` | `https://developers.google.com/apps-script/reference/document/horizontal-rule` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/horizontal-rule`. |
| `https://developers.google.com/apps-script/reference/document/element#asInlineDrawing()` | `https://developers.google.com/apps-script/reference/document/inline-drawing` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/inline-drawing`. |
| `https://developers.google.com/apps-script/reference/document/element#asInlineImage()` | `https://developers.google.com/apps-script/reference/document/inline-image` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/inline-image`. |
| `https://developers.google.com/apps-script/reference/document/element#asListItem()` | `https://developers.google.com/apps-script/reference/document/list-item` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/list-item`. |
| `https://developers.google.com/apps-script/reference/document/element#asPageBreak()` | `https://developers.google.com/apps-script/reference/document/page-break` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/page-break`. |
| `https://developers.google.com/apps-script/reference/document/element#asParagraph()` | `https://developers.google.com/apps-script/reference/document/paragraph` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/paragraph`. |
| `https://developers.google.com/apps-script/reference/document/element#asPerson()` | `https://developers.google.com/apps-script/reference/document/person` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/person`. |
| `https://developers.google.com/apps-script/reference/document/element#asRichLink()` | `https://developers.google.com/apps-script/reference/document/rich-link` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/rich-link`, for example, a link to a Google Sheets file. |
| `https://developers.google.com/apps-script/reference/document/element#asTable()` | `https://developers.google.com/apps-script/reference/document/table` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/table`. |
| `https://developers.google.com/apps-script/reference/document/element#asTableCell()` | `https://developers.google.com/apps-script/reference/document/table-cell` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/table-cell`. |
| `https://developers.google.com/apps-script/reference/document/element#asTableOfContents()` | `https://developers.google.com/apps-script/reference/document/table-of-contents` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/table-of-contents`. |
| `https://developers.google.com/apps-script/reference/document/element#asTableRow()` | `https://developers.google.com/apps-script/reference/document/table-row` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/table-row`. |
| `https://developers.google.com/apps-script/reference/document/element#asText()` | `https://developers.google.com/apps-script/reference/document/text` | Returns the current element as a `https://developers.google.com/apps-script/reference/document/text`. |
| `https://developers.google.com/apps-script/reference/document/element#copy()` | `https://developers.google.com/apps-script/reference/document/element#` | Returns a detached, deep copy of the current element. |
| `https://developers.google.com/apps-script/reference/document/element#getAttributes()` | `Object` | Retrieves the element's attributes. |
| `https://developers.google.com/apps-script/reference/document/element#getNextSibling()` | `https://developers.google.com/apps-script/reference/document/element#|null` | Retrieves the element's next sibling element. |
| `https://developers.google.com/apps-script/reference/document/element#getParent()` | `https://developers.google.com/apps-script/reference/document/container-element|null` | Retrieves the element's parent element. |
| `https://developers.google.com/apps-script/reference/document/element#getPreviousSibling()` | `https://developers.google.com/apps-script/reference/document/element#|null` | Retrieves the element's previous sibling element. |
| `https://developers.google.com/apps-script/reference/document/element#getType()` | `https://developers.google.com/apps-script/reference/document/element-type` | Retrieves the element's `https://developers.google.com/apps-script/reference/document/element-type`. |
| `https://developers.google.com/apps-script/reference/document/element#isAtDocumentEnd()` | `Boolean` | Determines whether the element is at the end of the `https://developers.google.com/apps-script/reference/document/document`. |
| `https://developers.google.com/apps-script/reference/document/element#merge()` | `https://developers.google.com/apps-script/reference/document/element#|null` | Merges the element with the preceding sibling of the same type. |
| `https://developers.google.com/apps-script/reference/document/element#removeFromParent()` | `https://developers.google.com/apps-script/reference/document/element#|null` | Removes the element from its parent. |
| `https://developers.google.com/apps-script/reference/document/element#setAttributes(Object)` | `https://developers.google.com/apps-script/reference/document/element#` | Sets the element's attributes. |

## Detailed documentation

### `asBody()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/body`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/body` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asDate()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/date`.

When you know an element is a `https://developers.google.com/apps-script/reference/document/date`, use this method to set its type as a `https://developers.google.com/apps-script/reference/document/date`. Doing so lets autocomplete in the Apps Script editor show you the methods you can use
with a `https://developers.google.com/apps-script/reference/document/date`.

#### Return


`https://developers.google.com/apps-script/reference/document/date` --- The current element with its type set as `https://developers.google.com/apps-script/reference/document/date`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asEquation()`

Returns the current element as an `https://developers.google.com/apps-script/reference/document/equation`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/equation` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asEquationFunction()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/equation-function`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/equation-function` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asEquationFunctionArgumentSeparator()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/equation-function-argument-separator`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/equation-function-argument-separator` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asEquationSymbol()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/equation-symbol`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/equation-symbol` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asFooterSection()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/footer-section`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/footer-section` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asFootnote()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/footnote`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/footnote` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asFootnoteSection()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/footnote-section`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/footnote-section` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asHeaderSection()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/header-section`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/header-section` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asHorizontalRule()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/horizontal-rule`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/horizontal-rule` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asInlineDrawing()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/inline-drawing`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/inline-drawing` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asInlineImage()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/inline-image`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/inline-image` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asListItem()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/list-item`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/list-item` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asPageBreak()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/page-break`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/page-break` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asParagraph()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/paragraph`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/paragraph` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asPerson()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/person`.

When you know an element is a `https://developers.google.com/apps-script/reference/document/person`, use this method to set its type as a person.
Doing so lets autocomplete in the Apps Script editor show you the methods you can use with a
person element.

#### Return


`https://developers.google.com/apps-script/reference/document/person` --- The current element with its type set as `https://developers.google.com/apps-script/reference/document/person`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asRichLink()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/rich-link`, for example, a link to a Google Sheets file.

When you know an element is a `https://developers.google.com/apps-script/reference/document/rich-link`, use this method to set its type as a `https://developers.google.com/apps-script/reference/document/rich-link`. Doing so lets autocomplete in the Apps Script editor show you the methods you can
use with a `https://developers.google.com/apps-script/reference/document/rich-link`.

#### Return


`https://developers.google.com/apps-script/reference/document/rich-link` --- The current element with its type set as `https://developers.google.com/apps-script/reference/document/rich-link`.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asTable()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/table`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/table` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asTableCell()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/table-cell`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/table-cell` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asTableOfContents()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/table-of-contents`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/table-of-contents` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asTableRow()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/table-row`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/table-row` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `asText()`

Returns the current element as a `https://developers.google.com/apps-script/reference/document/text`.

Use this method to aid auto-complete whenever a given element is known to be of a specific
type.

#### Return


`https://developers.google.com/apps-script/reference/document/text` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `copy()`

Returns a detached, deep copy of the current element.

Any child elements present in the element are also copied. The new element doesn't have a
parent.

#### Return


`https://developers.google.com/apps-script/reference/document/element#` --- The new copy.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `getAttributes()`

Retrieves the element's attributes.

The result is an object containing a property for each valid element attribute where each
property name corresponds to an item in the `DocumentApp.Attribute` enumeration.

```javascript
const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Append a styled paragraph.
const par = body.appendParagraph('A bold, italicized paragraph.');
par.setBold(true);
par.setItalic(true);

// Retrieve the paragraph's attributes.
const atts = par.getAttributes();

// Log the paragraph attributes.
for (const att in atts) {
  Logger.log(`${att}:${atts[att]}`);
}
```

#### Return


`Object` --- The element's attributes.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `getNextSibling()`

Retrieves the element's next sibling element.

The next sibling has the same parent and follows the current element.

#### Return


`https://developers.google.com/apps-script/reference/document/element#|null` --- The next sibling element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `getParent()`

Retrieves the element's parent element.

The parent element contains the current element.

#### Return


`https://developers.google.com/apps-script/reference/document/container-element|null` --- The parent element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `getPreviousSibling()`

Retrieves the element's previous sibling element.

The previous sibling has the same parent and precedes the current element.

#### Return


`https://developers.google.com/apps-script/reference/document/element#|null` --- The previous sibling element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `getType()`

Retrieves the element's `https://developers.google.com/apps-script/reference/document/element-type`.

Use `getType()` to determine the exact type of a given element.

```javascript
const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Obtain the first element in the active tab's body.

const firstChild = body.getChild(0);

// Use getType() to determine the element's type.
if (firstChild.getType() === DocumentApp.ElementType.PARAGRAPH) {
  Logger.log('The first element is a paragraph.');
} else {
  Logger.log('The first element is not a paragraph.');
}
```

#### Return


`https://developers.google.com/apps-script/reference/document/element-type` --- The element type.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `isAtDocumentEnd()`

Determines whether the element is at the end of the `https://developers.google.com/apps-script/reference/document/document`.

#### Return


`Boolean` --- Whether the element is at the end of the tab.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `merge()`

Merges the element with the preceding sibling of the same type.

Only elements of the same `https://developers.google.com/apps-script/reference/document/element-type` can be merged. Any child elements contained in
the current element are moved to the preceding sibling element.

The current element is removed from the document.

```javascript
const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Example 1: Merge paragraphs
// Append two paragraphs to the document's active tab.
const par1 = body.appendParagraph('Paragraph 1.');
const par2 = body.appendParagraph('Paragraph 2.');
// Merge the newly added paragraphs into a single paragraph.
par2.merge();

// Example 2: Merge table cells
// Create a two-dimensional array containing the table's cell contents.
const cells = [
  ['Row 1, Cell 1', 'Row 1, Cell 2'],
  ['Row 2, Cell 1', 'Row 2, Cell 2'],
];
// Build a table from the array.
const table = body.appendTable(cells);
// Get the first row in the table.
const row = table.getRow(0);
// Get the two cells in this row.
const cell1 = row.getCell(0);
const cell2 = row.getCell(1);
// Merge the current cell into its preceding sibling element.
const merged = cell2.merge();
```

#### Return


`https://developers.google.com/apps-script/reference/document/element#|null` --- The merged element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `removeFromParent()`

Removes the element from its parent.

```javascript
const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Remove all images in the active tab's body.
const imgs = body.getImages();
for (let i = 0; i < imgs.length; i++) {
  imgs[i].removeFromParent();
}
```

#### Return


`https://developers.google.com/apps-script/reference/document/element#|null` --- The removed element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`

*** ** * ** ***

### `setAttributes(attributes)`

Sets the element's attributes.

The specified attributes parameter must be an object where each property name is an item in
the `DocumentApp.Attribute` enumeration and each property value is the new value to be
applied.

```javascript
const doc = DocumentApp.getActiveDocument();
const documentTab = doc.getActiveTab().asDocumentTab();
const body = documentTab.getBody();

// Define a custom paragraph style.
const style = {};
style[DocumentApp.Attribute.HORIZONTAL_ALIGNMENT] =
    DocumentApp.HorizontalAlignment.RIGHT;
style[DocumentApp.Attribute.FONT_FAMILY] = 'Calibri';
style[DocumentApp.Attribute.FONT_SIZE] = 18;
style[DocumentApp.Attribute.BOLD] = true;

// Append a plain paragraph.
const par = body.appendParagraph('A paragraph with custom style.');

// Apply the custom style.
par.setAttributes(style);
```

#### Parameters

| Name | Type | Description |
|---|---|---|
| `attributes` | `Object` | The element's attributes. |

#### Return


`https://developers.google.com/apps-script/reference/document/element#` --- The current element.

#### Authorization

Scripts that use this method require authorization with one or more of the following [scopes](https://developers.google.com/apps-script/concepts/scopes#setting_explicit_scopes):

- `https://www.googleapis.com/auth/documents.currentonly`
- `https://www.googleapis.com/auth/documents`