Blog Title : A Css Selcetor

23-08-2021

What is a selector?:

A selector is an element of an HTML tag, any class, id.

How :

you have below code in your html page

Now you want to apply CSS on the p tag. how you can do this. To apply CSS on the p tag. You should apply CSS like below code

Now I will tell you some selector name list

1. Universal Selector
2. Type Selector
3. Class Selector
4. Id Selector
5. Attibute Selector
6. Grouping Selector

let Explain every selector one by one.


Universal Selector :

In CSS, * is a universal selector that applies CSS to every element.

Note: after applying this CSS every HTML element on the page to have blue text.

Type Selector :

a type selector matches the HTML tag and then apply

Note: This rule causes every

element to have 2em of padding on all sides.


Class selector:

class is an HTML tag attribute. In this class attribute, we define many CSS classes.

In the above code, there is a class "my-class" for this, we can apply CSS like this


ID selector:

An HTML element with an id attribute should be the only element on a page with that ID value. You select elements with an ID selector like this:


Attribute selector:

Instruct CSS to look for attributes by wrapping the selector with square brackets ([ ]).

This CSS looks for all elements that have an attribute of data-type with a value of primary, like this:


Grouping selectors:

A selector don't have to match only a single element. You can group multiple selectors by separating them with commas:

This example extends the color change to both strong and em. It's also extended to a class named .my-class, and an element that has a lang attribute.