> ## Documentation Index
> Fetch the complete documentation index at: https://docs.extractbase.com/llms.txt
> Use this file to discover all available pages before exploring further.

# element

Queries the current context (Page or Element) for a single element matching the specified criteria.
If multiple elements match, the first one is returned. Returns null if no element is found.
Supports various selector strategies including CSS selectors, text content, ARIA roles, and more.
Example: `element(selector: ".my-class", text: "Submit")`

## Definition

```graphql theme={null}
element(
  selector: String
  text: String
  role: ARIARole
  label: String
  placeholder: String
  altText: String
  title: String
  testId: String
  filter: ElementFilterOptions
): Element
```

## Arguments

### `selector`

[String](/reference/graphql/scalars/string)

The CSS selector for the element. Example: `"#username"` for `<input id="username" />`.

### `text`

[String](/reference/graphql/scalars/string)

Finds an element by its text content. Example: `"Login"` for `<button>Login</button>`.

### `role`

[ARIARole](/reference/graphql/enums/ariarole)

Finds an element by its ARIA role. Example: `"button"` for `<div role="button">Submit</div>`.

### `label`

[String](/reference/graphql/scalars/string)

Finds an element by its ARIA label. Example: `"Search button"` for `<button aria-label="Search button"><svg/></button>`.

### `placeholder`

[String](/reference/graphql/scalars/string)

Finds an element by its placeholder text. Example: `"Enter your email"` for `<input placeholder="Enter your email" />`.

### `altText`

[String](/reference/graphql/scalars/string)

Finds an element by its image alt text. Example: `"Company logo"` for `<img alt="Company logo" src="..." />`.

### `title`

[String](/reference/graphql/scalars/string)

Finds an element by its title attribute. Example: `"Close dialog"` for `<span title="Close dialog">X</span>`.

### `testId`

[String](/reference/graphql/scalars/string)

Finds an element by its data-testid attribute. Example: `"submit-button"` for `<button data-testid="submit-button">Go</button>`.

### `filter`

[ElementFilterOptions](/reference/graphql/inputs/element-filter-options)

Advanced filtering options for the element.

## Returns

[Element](/reference/graphql/objects/element)

Represents a single HTML element on a web page.
It provides properties and methods to query the state and content of the element.
The Element type implements the `Node` interface, inheriting common element-querying capabilities.
Instances of Element are typically obtained by querying a Page or another Element.

## Usage

This field is available on the [Page](/reference/graphql/objects/page) object. Use it to query page information and content.
