Skip to main content

Command Palette

Search for a command to run...

CSS Selectors

Published
2 min readView as Markdown
CSS Selectors
A

Full-Stack Web Developer

CSS Selectors are used to select the HTML elements you want to style. We can divide CSS Selectors into five Categories:-

1) CSS Element Selector 2) CSS ID Selector 3) CSS Class Selector 4) CSS Universal Selector 5) CSS Group Selectors

CSS Element Selector The element selector finds element based on the tag. This selector is used to apply some style formatting to particular tag type.

This is sample text

CSS ID Selector The #Id selector style the element with the specified ID. ID selector works in two steps.

  • First assign and ID to HTML tag

  • To apply style with ID selector, By the ID of the element. #blue-text {

This is an example of paragraph text.

Class Selectors The class selector selects specific elements based on the class attribute. It works in two types:-

  • A class can be assigned to any HTML tag using class attribute.

     <p class="green -text">
    
  • Class selector use dot(.) or period character followed by class name.

      .green-text{ color: green}
    

This is an example of paragraph text.

CSS Universal The universal selector provide by CSS in choosing any elements within the HTML page. It is defined by an asterisk (*)

sample-text

this is a headings

CSS Group selector

The grouping selectors is used to combine all the elements that need the same style rules. You can apply a style to multiple selectors by separating the selectors with a comma(,).