It appears that the information provided on the linked page is incorrect (cue the sounds of discontent directed towards W3Schools). The selectors listed there are specifically for jQuery, which are considered non-standard and not valid CSS selectors despite their similar syntax.
While the :first
pseudo-class is designated for use within the @page
rule, it is not meant to be utilized elsewhere. For example, a selector like p:first
is not valid in a style rule, @page
rule, or even in a document.querySelectorAll()
function. Page selectors are unique selectors explained in detail in the CSS2.1 documentation and Paged Media module documentation. Although they are part of the CSS standard, they are separate from the Selectors standard, resembling jQuery selectors only in terms of syntax.
Regarding :first
, it is also defined in jQuery but functions differently compared to its usage in a @page
rule. The page you referenced demonstrates jQuery's interpretation of :first
. It may be more accurate to consider :first
as a valid page selector or jQuery selector due to its context-specific nature, incapable of being used in CSS stylesheets or document.querySelectorAll()
.
Similar to :first
, :eq()
and related selectors are exclusive to jQuery and differ significantly from CSS equivalents like :first-child
and :nth-child()
. While CSS can mimic some functionalities using traditional selectors, jQuery introduced these unique selectors for specific purposes. Refer to my response to this query for a detailed explanation.
Furthermore, although :contains()
was initially planned for inclusion in CSS specifications, it never materialized. Its functionality has been replicated in jQuery; however, caution must be exercised due to potential performance impact or unexpected behavior.