Comparison of CSS Selectors and XPath
本文旨在记录 CSS 选择器和 XPath 之间的区别,以便 Web 开发人员能够更好地为正确的工作选择合适的工具。
| XPath feature | CSS equivalent | 
|---|---|
ancestor (en-US), parent (en-US) or preceding-sibling (en-US) axis | 
      :has() selector 
    实验性
 | 
    
attribute (en-US) axis | 
      Attribute selectors | 
child (en-US) axis | 
      Child combinator | 
descendant (en-US) axis | 
      Descendant combinator | 
following-sibling (en-US) axis | 
      General sibling combinator or adjacent sibling combinator | 
self (en-US) axis | 
      :scope or :host selector |