---
title: "Selection.single(selector) | Grafana k6 documentation"
description: "Returns at most one element matching the selector."
---

> For a curated documentation index, see [llms.txt](/llms.txt). For the complete documentation index, see [llms-full.txt](/llms-full.txt).

# Selection.single(selector)

Returns at most one element matching the selector, as a [Selection](/docs/k6/latest/javascript-api/k6-html/selection/) object. It’s backed by goquery’s `Single` matcher, which is faster than [find()](/docs/k6/latest/javascript-api/k6-html/selection/selection-find/) when you only need the first match.

Expand table

| Parameter | Type   | Description                                                          |
|-----------|--------|----------------------------------------------------------------------|
| selector  | string | A string containing a selector expression to match elements against. |

### Returns

Expand table

| Type                                                           | Description       |
|----------------------------------------------------------------|-------------------|
| [Selection](/docs/k6/latest/javascript-api/k6-html/selection/) | Selection object. |

### Example

JavaScript ![Copy code to clipboard](/media/images/icons/icon-copy-small-2.svg) Copy

```javascript
import { parseHTML } from 'k6/html';
import http from 'k6/http';

export default function () {
  const res = http.get('https://k6.io');
  const doc = parseHTML(res.body);

  const title = doc.single('h1').text();
}
```
