Skip to content

Latest commit

 

History

History
47 lines (32 loc) · 820 Bytes

css-selector.md

File metadata and controls

47 lines (32 loc) · 820 Bytes

CSS Selectors

CSS selectors are used to select and apply styles to specific HTML elements.

  • Element Selector: This selector targets all instances of a specific HTML element on the page.
p {
  color: blue;
}

  • Class Selector: This selector targets all elements that have a specific class attribute value.
.myClass {
  text-align:center;
}

  • ID Selector: This selector targets a single element with a specific ID attribute value.
#myId {
  background-color: royalblue;
}
  • Descendant Selector: This selector targets elements that are descendants of a specific parent element.
.parentElement li {
  list-style: none;
}
  • Attribute Selector: This selector targets elements with a specific attribute value.
input[type="text"] {
  color:red;
}