---
hide_title: false
hide_table_of_contents: false
pagination_next: null
pagination_prev: null
---

# before

The `before` method inserts content before the opening tag of the element.

## Syntax

```js
element.before(content);
element.before(content, options);
```

### Parameters

- `content` _: string_
  - The content to insert before the element's opening tag.

- `options` _: ElementRewriterOptions_
  - An optional object that can have the following properties:
    - `escapeHTML` _: boolean_
      - If `true`, any HTML markup in `content` will be escaped so it is safe to insert as text.

### Examples

```js
// Assuming `e` is an Element representing <div>Hello</div>
e.before("Well");
// Result: Well<div>Hello</div>
```
