Selectors...

·

2 min read

Simple Selectors

  1. Universal Selector.

  2. Element Selector.

  3. Class Selector.

  4. ID Selector.

  5. Selector list.

Universal

The CSS universal selector (*) matches elements of any type.

(isse universal selectors kehte h, jo html file/documnet ke saare tag ko select kar leta h)

Output

2.Element Selector

The Element Selector only selects all the instances of a tag or element present on the webpage.
(direct HTML tag ko select karke)

Output

3.Class Selector

The CSS class selector is probably the most useful and used selector, it selects all elements that have given the class value in their class attribute.

To select elements with a specific class, write a period (.) character, followed by the name of the class.

Output

4.Id Selector

ID selectors are the most powerful in terms of CSS specificity, just like the class selector, it targets specific elements in our HTML document that we can then use as a reference in our CSS.

To select an element with a specific id, write a hash (#) character, followed by the id of the element.

Output

5.Selector List

The CSS selector list (,) allows us to select multiple elements with different selectors at once and style them.

We have more than one thing which uses the same CSS then the individual selectors can be combined into a selector list so that the rule is applied to all of the individual selectors.

Output

DAY_14 31_Jan(Tue)_2023

Did you find this article valuable?

Support B1 by becoming a sponsor. Any amount is appreciated!