CSS selectors and your Browser Console
Like the notation we used to extract using cssselect
, CSS selectors are patterns used for selecting HTML elements. Here are some examples of common selectors you should know:
Select any tag: * Select by tag <a>: a Select by class of "link": .link Select by tag <a> with class "link": a.link Select by tag <a> with ID "home": a#home Select by child <span> of tag <a>: a > span Select by descendant <span> of tag <a>: a span Select by tag <a> with attribute title of "Home": a[title=Home]
The cssselect
library implements most CSS3 selectors, and details on unsupported features (primarily browser interactions) are available at https://cssselect.readthedocs.io/en/latest/#supported-selectors.
Note
The CSS3 specification was produced by the W3C and is available for viewing at http://www.w3.org/TR/2011/REC-css3-selectors-20110929/. There is also a useful and more accessible documentation from Mozilla on their...