# selector

## Table of Contents

- [Fallback selectors](#fallback-selectors)

---

Type:

\<string\> \| \<string\[\]\>

\
Values: [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors)

It defines the [HTML element](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) you want to pick from the HTML markup over the [url](https://microlink.io/docs/api/parameters/url):

```js
importcreateClientfrom'microlink.io'

constmicrolink=createClient()

constgithub=username=>

microlink.extract(`https://github.com/${username}`,{

avatar:{

selector:'meta[property="og:image"]:not([content=""])',

attr:'content',

type:'image'

}

})

constusername='kikobeats'

const{avatar}=awaitgithub(username)

console.log(

`GitHub avatar for @${username}: ${avatar.url} (${avatar.size_pretty})`

)
```

It's equivalent to [Document.querySelector()](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector) and any [CSS selector](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Selectors) can be specified, such as:

- An HTML tag (e.g., 'img').
- A CSS class or pseudo-class, id or data-attribute (e.g., '#avatar').
- A combination of both (e.g., 'img:first').

When `selector` is omitted, [attr](https://microlink.io/docs/sdk/methods/extract/attr) operates on the entire page — see [whole-page serialization](https://microlink.io/docs/sdk/methods/extract/attr#whole-page-serialization). The same `selector` is what the [markdown](https://microlink.io/docs/sdk/methods/markdown), [html](https://microlink.io/docs/sdk/methods/html), [text](https://microlink.io/docs/sdk/methods/text), and [links](https://microlink.io/docs/sdk/methods/links) methods accept as an option to scope their extraction.

## Fallback selectors

A collection of selectors is an array of [fallback rules](https://microlink.io/docs/sdk/methods/extract#fallback-rules): the first selector that yields a typed value wins.