View video tutorial

CSS Selectors

CSS

A CSS selector selects one or more HTML element(s) to apply styles to.

CSS Selectors


Selectors are used to select one or more HTML elements that we want to style.

There are five categories of selectors that are used to select elements.

Basic selectors (selection is based on element name, id, class).

Combinator selectors (selection is based on relationships between elements).

Pseudo-class selectors (selection is based on the element certain state).

Pseudo-element selectors (select a part of an element and style it).

Attribute selectors (selection is based on element attributes or attribute values).

Practice with examples "Try it Now"

You can practice the Oracle command in your machine by following examples.

To see the output for every example click "Try it Now"

Example

<style>
  p {
    font-style: italic;
    color: red;
  }
</style>
Try it Now »

Click on the "Try it Now" button to see how it works.


Sample Code

Copy each file contents and paste it to your own project and run to see the final output