ID and class selectors are additional features available with element selectors. We can find HTML tags with the class and id attributes. These are also known as global attributes. These attributes are mostly preferred over other attributes as they define the tags for structure and with identification.
For more details on global attributes, please refer to Chapter 1, Web Scraping Fundamentals, the Global attributes section. The following table lists the usage of this category of selectors:
CSS query |
Description |
.header |
Selects an element with class=header |
.plan |
Selects <a> with class=plan |
div.links |
Selects <div> with class=plan |
#link |
Selects an element with id=link |
a#link |
Selects <a> elements with id=link |
a.plan |
Selects <a> elements with class=plan |