Comparison of CSS Selectors and XPath

草案: 本页尚未完工.

本文旨在记录CSS选择器和XPath之间的区别,以便Web开发人员能够更好地为正确的工作选择合适的工具。

XPath feature CSS equivalent
ancestor, parent or preceding-sibling axis :has() selector
attribute axis Attribute selectors
child axis Child combinator
descendant axis Descendant combinator
following-sibling axis General sibling combinator or adjacent sibling combinator
self axis :scope or :host selector