Styling is an important concept that brings CSS to the top of web designing. Like other elements, selectors in CSS also help in selecting the styles in elements you want to put for designing your web pages. In this chapter, you will get to know about the concept of selectors in CSS.
What Are Selectors in CSS?
CSS selectors are implemented for selecting the substance of your web page you wish to style. These selectors act as the components of the rule set of CSS. CSS selectors choose elements in HTML based on the class, id, attribute, type, etc.
- Selectors are those names that you give to your different styles.
- In the definition of style, you define how each selector should work (size, color, etc.).
- Then, in HTML pages, you mention these selectors to implement styles.
There are few basic types of selectors in the CSS from the initial version, and various upcoming versions of CSS have introduced many other selectors. Some of them are:
By applying all the above selectors, you will find that you can apply the same or different style to all HTML elements and tune them by adding ID, class, or by adding selectors for specific elements. We will discuss these selectors in detail from the next chapter.