concept

Page selector specificity — CSS reference

Page selector specificity uses page names, first/blank pseudo-classes and left/right pseudo-classes in descending significance. A :first rule outranks a :right rule regardless of their order when both match, assuming otherwise equal cascade conditions. This fixture demonstrates only that comparison.

Formal Syntax & Structure

css syntaxcss
@page :first { @top-center { content: "FIRST"; } }

Working Example

Example Snippetcss
<!doctype html><html lang="en"><meta charset="utf-8"><title>Page selector specificity</title><style>body{margin:0}#a{padding:8px;background:rgb(232,237,241);color:rgb(0,0,0);box-sizing:border-box}p{margin:0;font:12px/16px sans-serif}.next{break-before:page}@page{size:300px 400px;margin:40px;}@page :first{@top-center{content:"FIRST"}} @page :right{@top-center{content:"RIGHT"}}</style><body><main><p>BODY</p></main></body></html>
CSS Reference