---
title: "closest method"
url: "https://reference.aspose.com/html/python-net/aspose.html/htmllabelelement/closest/"
product: "Aspose.HTML for Python via .NET API References"
---


## closest {#str}

Returns the closest ancestor element (or the element itself) that matches the specified CSS selector.


### Returns 


The closest matching element; otherwise, `null`.


```python
def closest(self, selector):
    ...
```


| Parameter | Type | Description |
| :- | :- | :- |
| selector | str | The selector. |



### See Also
* module [`aspose.html`](../../)
* class [`Element`](/html/python-net/aspose.html.dom/element)
* class [`HTMLLabelElement`](/html/python-net/aspose.html/htmllabelelement)
