# has-class()

```
boolean has-class(string|node-set class_name [, node-set context])
```

The function `has-class` checks whether an element has a `class` attribute which contains the given CSS class name. The search is case-insensitive. If no `context` parameter is given, the current context node is used.

## Examples

`//*[has-class('myClass')]` returns all elements which contain the class name `myClass` in their `class` attributes.

`has-class('myClass', /*)` returns `true` if the document element contains `myClass` in its `class` attribute, otherwise `false`.

Searching for multiple class names simultaneously (e.g. `has-class('a b')`) is not supported and triggers a warning. Use an `and` or an `or` expression instead, e.g. `has-class('a') and has-class('b')`.

Searching an empty string is also not allowed and triggers a warning.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://sevenval.gitbook.io/flat/reference/functions/has-class.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
