CSS Selectors

CSS depends on pattern matching rules in order to determine the style that is applicable the most to every element put in that document. These patterns are actually called as selectors and it is ranging from tag names.

CSS Selectors

As a matter of fact, there are different kinds of selectors in CSS that are used by programmers and these include but not limited to the following:

  • Type selectors – this matches specific element
  • Class selectors – this matches elements together w/a specific class
  • ID selectors – its job is to match element with specific ID
  • Descendant selectors – matches elements that are the descendant of specific element
  • Child selectors – this one matches elements that are child of a given element
  • Universal selectors – a CSS selector that can match any element
  • Adjacent sibling selector – immediately match elements preceded by specific element
  • Attribute selectors – if you need to match elements with specific attribute value or attribute, then this is what’s used.

Caution for Your CSS Selectors

Regardless of the CSS selector that you use, you need to know that not all browsers are supporting it.

Having said that, it will be very smart of you to test every selector in various browsers on other OS as you could.

But if you’re using selectors from CSS1 or CSS2, then you should be just fine.