---
id: api/commands/first
title: first | Cypress Documentation
description: Get the first DOM element within a set of DOM elements in Cypress.
section: api
source_path: docs/api/commands/first.mdx
version: 8735fe877e6f589486e1059bc9412787edcb413d
updated_at: '2026-05-26T21:47:50.835Z'
---
# first

Get the first DOM element within a set of DOM elements.

The querying behavior of this command matches exactly how [`.first()`](http://api.jquery.com/first) works in jQuery.

## Syntax

```
.first().first(options)
```

### Usage

**Correct Usage**

```
cy.get('nav a').first() // Yield first link in nav
```

**Incorrect Usage**

```
cy.first() // Errors, cannot be chained off 'cy'cy.getCookies().first() // Errors, 'getCookies' does not yield DOM element
```

### Arguments

**options _(Object)_**

Pass in an options object to change the default behavior of `.first()`.

| Option | Default | Description |
| --- | --- | --- |
| `log` | `true` | Displays the command in the [Command log](/llm/markdown/app/core-concepts/open-mode.md#Command-Log) |
| `timeout` | [`defaultCommandTimeout`](/llm/markdown/app/references/configuration.md#Timeouts) | Time to wait for `.first()` to resolve before [timing out](#Timeouts) |

### Yields [Learn about subject management](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Subject-Management)

*   `.first()` yields the new DOM element it found.
*   `.first()` is a query, and it is _safe_ to chain further commands.

## Examples

### No Args

#### Get the first list item in a list

```
<ul>  <li class="one">Knick knack on my thumb</li>  <li class="two">Knick knack on my shoe</li>  <li class="three">Knick knack on my knee</li>  <li class="four">Knick knack on my door</li></ul>
```

```
// yields <li class="one">Knick knack on my thumb</li>cy.get('li').first()
```

## Rules

### Requirements [Learn about chaining commands](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Chains-of-Commands)

*   `.first()` requires being chained off a command that yields DOM element(s).

### Assertions [Learn about assertions](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Assertions)

*   `.first()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until the element(s) [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).
*   `.first()` will automatically [retry](/llm/markdown/app/core-concepts/retry-ability.md) until all chained assertions have passed.

### Timeouts [Learn about timeouts](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Timeouts)

*   `.first()` can time out waiting for the element(s) to [exist in the DOM](/llm/markdown/app/core-concepts/introduction-to-cypress.md#Implicit-Assertions).
*   `.first()` can time out waiting for assertions you've added to pass.

## Command Log

**_Find the first input in the form_**

```
cy.get('form').find('input').first()
```

The commands above will display in the Command Log as:

When clicking on `first` within the command log, the console outputs the following:

## See also

*   [`.eq()`](/llm/markdown/api/commands/eq.md)
*   [`.last()`](/llm/markdown/api/commands/last.md)
