## Element.Closest method

Returns the closest ancestor element (or the element itself) that matches the specified CSS selector.

```csharp
public Element Closest(string selector)
```

| Parameter | Type | Description |
| --- | --- | --- |
| selector | String | The selector. |

### Return Value

The closest matching element; otherwise, `null`.

### See Also

* class [Element](../)
* namespace [Aspose.Html.Dom](../../../aspose.html.dom/)
* assembly [Aspose.HTML](../../../)
