Skip to main content

Command Palette

Search for a command to run...

Guide to CSS Selectors

Updated
โ€ข2 min readโ€ขView as Markdown
Guide to CSS Selectors
D

Hello World, I'm Deepak Malik๐Ÿ‘‹

I am a Developer, Programmer and a Learner.

๐Ÿ”ญ Iโ€™m currently learning full stack web development.

๐Ÿ‘ฏ Iโ€™m looking to collaborate on interesting development projects.

โšกI can speak 3 languages ( English, Hindi and Punjabi).

๐Ÿ… ๐†๐ข๐ญ๐‡๐ฎ๐› ๐๐ซ๐จ๐Ÿ๐ข๐ฅ๐ž: https://github.com/deepakmalikk

๐Ÿ’ป Web technology: โ€ข HTML5 โ€ข CSS โ€ข JavaScript

Programming languages: โ€ข C โ€ข C++

๐Ÿ™ Thank you for reading. Have a wonderful day๐Ÿค—

CSS selectors

CSS selectors are used to find the html elemnts which you want to style.

Types of CSS selector :-

1. Universal Selector ->

This selector is used to select all the elements of html document. Universal Selector.png

2. individual Selector ->

By using this selector we can target particular html tag.

Individual Selector.png

3. Class And Id selector ->

  • These selectors are used to target html element by using their class attribute name or id attribute name.

  • They are most commonly used Selectors.

Class Selector

By using dot (".") we can target any class attribute from the html document.

class selector.png

Id Selector

By using Hash("#") we can target any id attribute from the html document.

Id selector.png

4. And Selector (chained) ->

It helps to select a particular element having one or more than one classes and ids.

and selector.png

5. Combined Selector ->

when we have to give same style to many html element then we use combined selector to target them.

combined selector.png

6. Inside an element selector->

This selector is used to target the specific element of the html document. Inside an element selector.png

7. Direct Child selector->

When we have to target the specific direct child of an html element that time we use direct child selector. By using greater than symbol (">").

Direct Child Selector.png

8. Sibling ~ or + Selector ->

Adjacent sibling selector (+): It will select the second element which immediately follows the first specified element. Sibiling + Selector.png General sibling selector(~): It will select all the sibling element which follows the first specified element.

Sibiling _ Selector.png