What is the CSS selecters?

What is the CSS selecters?

what is the Css Selecters?

  • Css selectors are used to select the content you want to style. -selecters are the part of CSS rule set.
  • Css selectors select HTML elements accordings to its id,class,type etc.

Tpes of CSS selectors

  1. Class selectors
  2. Id selectors
  3. Elements selectors
  4. Group selectors
  5. Universal selectors.

Group Selectors

  • The grouping selectors is used to select all the elements with the same style definations.
  • grouping selector is used to minimize the code.
  • commas are used to seprate each selector in grouping.

- without group selector h1 {
text-align: center;
color: blue;
}
h2 {
text-align: center;
color: blue;
}
p {
text-align: center;
color: blue;
}

- with group selector. h1,h2,p {
text-align: center;
color: blue;
}

Element selector

  • The element selector select the HTML element by name.

ElementName{
text-align: center;
color: blue;
}

Id selectors

  • The id selector selects the id attributes of an HTML element to select a specific element.
  • An id alwayss unique within the page so it chosen to select a single, unique element.
  • It is written with the hash character (#), followed by the id of the element.

#IdNAme {
text-align: center;
color: blue;
}

Class Selectors

  • The class selector HTML element with a specific class attributes.
  • It is used with a period character.

.ClassName {
text-align: center;
color: blue;
}

  • class selector for spacific Element

p.center {
text-align: center;
color: blue;
}

Universal selector

  • the universal character is used as a whildcard character and it select all the element on the page.

<!DOCTYPE html>






This is heading


This style will be applied on every paragraph.


Universal selectors


selectors