Selectors in CSS
Jeevan Henry Dsouza
Full Stack Developer | JavaScript | React | MySQL | NodeJS | SpringBoot | Monolith | MicroServices | SaaS | Frontend Development | User Interface Design
Selectors in CSS
The purpose of? HTML is to structure the data into different sections on the webpage. Example word document. The word document has different sections like header footer etc. Along similar lines, we have a webpage with different sections like body title, paragraph etc. We need to style the different sections on the webpage. This is done using CSS. First, we need to select the individual elements to apply some styling to them. In CSS we do this using? CSS selectors.
The different types of selectors are:
1. Simple Selectors :
a.Class selector: In this selector, we group multiple HTML elements to form a class then we apply the necessary styling to all the elements present in that particular class.
b. id selector: Same as class selectors but the only drawback is we can use only one id to select only one particular HTML element?
2. Combinator Selectors:
These are used to explain the relationship between two CSS selectors. The selection will happen based on the relationship between the selectors
3. Pseudo-Selectors:
There are two types of pseudo-selectors :
领英推荐
1. pseudo-class selector
2.pseudo-element selector
1:Pseudo Classes:
The word pseudo in English means: not actually but having the appearance of.
Pseudo is a keyword which is added before a selector to identify a special state or representation.
When used before a selector, the class will be styled only when that particular thing happens on the webpage. For example, a word changes its colour only when we hover the mouse over it. Till the time we do not hover over it the styling will not be applied hence they are given the name as pseudo
2. Pseudo Elements:
Pseudo Elements are called pseudo because they are virtual elements that are they are not present in the Document Object Model and rendered by the browser