Continuous Test Orchestration And Execution Platform Online

Perform automated and live-interactive testing on 3000+ real desktop and mobile devices online.

What are Selectors in CSS?

Using CSS selectors is the best way to target HTML elements. Selectors are used in CSS rule sets to select the content you want to style. They are part of a CSS rule set, a set of instructions used by a web browser to determine which HTML elements should be styled with CSS.

There are many different types of CSS selectors:

  • CSS Element Selector: The element selector allows you to select the HTML element by name.
  • CSS Id Selector: The id selector selects a single element on a page. It is written using the hash character (#), followed by the id. The id attribute is always unique for each element so that this selector can select only the specific element with the given id.
  • CSS Class Selector: The class selector matches elements with a specific class attribute. It is written with a period character followed by the class name.
  • CSS Universal Selector: The universal selector (@namespace) is a special type selector that can be namespaced when using @namespace. This can be helpful when dealing with documents containing multiple namespaces, such as HTML with inline SVG or MathML or XML that mixes multiple vocabularies.
  • CSS Group Selector: Grouping selectors allow you to apply common styles to several elements simultaneously. To group selectors, separate each selector by a space. This reduces the amount of code and effort required to give multiple elements the same appearance.
LambdaTest

Test your websites, web-apps, or mobile apps seamlessly with LambdaTest.

Start Free Testing
LambdaTest

Earn resume-worthy Selenium certifications that help you land a top job.

Learn More
LambdaTest

Test your web or mobile apps

Test orchestration and execution cloud of 3000+ browsers and OS

Support

24/7 support

Security

Enterprise grade security

Cloud

Fastest test execution cloud