Selectors in CSS:

With the help of CSS selectors you can select the HTML element and also manipulate that HTML element with the CSS code.

Types:

There are mainly three types of selectors which are commonly used they are as follows:

  • The Element Selector
  • The Class Selector
  • The Id Selector

The Element Selector:

You can apply properties directly to the HTML element based on the element name.

Example:

In following example we are directly applying style properties to the paragraph.

The Class Selector:

You can also apply style properties by using class. First of all you have to create a class and the class name should start with the dot “.” character after that you can use that class name in HTML elements by calling them.

Example:

In following example we are creating a class and than calling that class into the paragraph.

The ID Selector:

You can also apply style properties by using id. First of all you have to create a id and the id name should start with the dot “#” character after that you can use that id name in HTML elements by calling them.

The id name should be unique within the page.

Example:

In following example we are creating a id and than call that id where you want that style

Grouping Selectors:

You can also group the selector. If the HTML elements have same properties so that you can group them in a single selector.

Example:

 

2 responses to “Selectors in CSS”

  1. Van Hussy says:

    I like what you guys are up to. Such clever work and reporting! Carry on with the excellent works guys. I’ve incorporated you guys to my blogroll. I think it’ll improve the value of my site. 🙂

  2. Salvatore Bory says:

    Thanks for a marvelous posting! I genuinely enjoyed reading it, you’re a great author.I will make sure to bookmark your blog and will come back later on. I want to encourage you to ultimately continue your great job, have a nice afternoon!

Leave a Reply

Your email address will not be published. Required fields are marked *