CSS Selectors

List 10 and deminstrate 3 CSS3 selectors

  1. p:first-of-type
  2. Selects every p element that is the first p element of its parent

    Demonstrated: changed Background color

  3. :root
  4. Selects the document's root element

  5. element1~element2 p ~ ul (Deminstrated)
  6. Selects every ul element that are preceded by a p element

    The first paragraph.

  7. [attribute^=value] a[href^="https"] (deminstrated
  8. Selects every a element whose href attribute value begins with "https"

    This is a div with a class of "test".

  9. [attribute$=value] a[href$=".pdf"]
  10. Selects every a element whose href attribute value ends with ".pdf"

  11. :checked input:checked
  12. Selects every checked input element

  13. :disabled input:disabled
  14. Selects every disabled input element

  15. :empty p:empty
  16. Selects every p element that has no children (including text nodes)

  17. :enabled input:enabled
  18. Selects every enabled input element

  19. :not(selector) :not(p)
  20. Selects every element that is not a p element