CSS Selector  part-1

CSS Selector part-1

One of the Most useful things in CSS

  • In CSS the most important thing you know that how to target any element for that you need to know many selectors. who select element for you for the styling
  • there are many selector you never used and there are many which you used frequently

THERE ARE LOT OF CSS SELECTORS We talk about some of them

1) Universal Selector

  • the Universal selector indicates with *
  • it select the whole background of page

1.png

OUTPUT:-

image.png

2) Type Selector

  • select the elements of that type
  • the Type selector indicates with Element type

2.png

OUTPUT:-

image.png

Class and ID Selector

## 3)Class Selector

  • the class selector indicates with . class name

3.png OUTPUT:- image.png

4)ID Selector

  • the id selector indicates with #id name

4.png OUTPUT:-

4.4.png

Combination

##

5)Descendant Selector

  • Here You can select content with Element.class

5.png

OUTPUT:-

5.5.png

6) Or Selector

  • Select elements or multiple elements l anchors and all div
  • Element, Element

6.png OUTPUT:-

image.png

7) And Selector

  • Select elements that match all the selector combinations Selects all divs with the class blue
  • all sameElement.sameClass

7.png

OUTPUT:-

7.7.png

8)Inside Selector

  • element element
  • element element.class
  • element .class

8.png

9)Direct Child Selector

  • Select elements that are direct children of the first element .
  • Select anchors that are direct children of a div
  • here you select content with parent element with first child element

9.png

Sibling Selectors


10)General Sibling

  • Select elements that are siblings of the first element and come after the first element
  • Selects all anchors that are siblings of a div and come after the div
  • applies all the sibling after that selected element
  • element.class~element

10.png OUTPUT:-

10.10.png

11)Adjacent Sibling

  • Select elements that are siblings of the first element and come directly after the first element
  • Selects all anchors that are siblings of a div and come directly after the div
  • applies the only sibling after that selected element

11.11.png OUTPUT:-

11.png

Pseudo Class

12)Hover Selector

  • Select elements that are hovered by the mouse .Select buttons that are being hovered

image.png OUTPUT:-

image.png

13)focus Selector

  • Select elements that are focused.
  • Select buttons that are being focused
  • Focus is set by either tabbing to an element or clicking an element such as a button or anchor tag

image.png

OUTPUT:-

image.png

14)Required Selector

  • Select inputs that are required
  • Select inputs with the required attribute

image.png

OUTPUT:-

image.png

  • there are many selector we can checkout in next article