Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<Dom\ParentNode::prependDom\ParentNode::querySelectorAll>
^Dom\ParentNodeLast updated: Mon, 26 Oct 2026

Dom\ParentNode::querySelector

(PHP 8 >= 8.4.0)

Dom\ParentNode::querySelector — Returns the first element that matches the CSS selectors

Description

public function Dom\ParentNode::querySelector(string $selectors): ?Dom\Element

Returns the first element that matches the CSS selectors specified in selectors.

Parameters

selectors

A string containing one or more CSS selectors.

Return Values

Returns the first Dom\Element that matches selectors. Returns null if no element matches.

Errors/Exceptions

Throws a DOMException with code Dom\SYNTAX_ERR when selectors is not a valid CSS selector string.

See Also


<Dom\ParentNode::prependDom\ParentNode::querySelectorAll>
^Dom\ParentNodeLast updated: Mon, 26 Oct 2026