Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Explain what a class selector is and how it’s used?

user-image
Question added by Anirban Chakraborty , Network Administrator , Wipro Limited
Date Posted: 2016/12/02

Class selector is used to style html element In easy way.

 

It s defined in style sheet file by a dot and is applied by class attribute in html tag.

Basic html only creates a mock up of the web page but that does not look beautiful or according to your needs. Cascading style sheet is used for this purpose. 

So what are the xhanges can be made by using class attribute and styling sheet. 

Well it depends on the html object or content you are working on but most common things are borders, text colors, background colors, width, height, margins, paddings and much more. 

So if you have heard about Id selector you may think whats the difference.

Id is used to style only one type of specific element like a button or a comment or any content. 

But class selector is used in styling more than one contents and objects. Like you can have a class named. fullwidth and you can assign this class to any element you want to be a element having full width.

alaa liswe
by alaa liswe , ِAdministrative Assistant , Arab Open University

The universal selector works like a wild card character, selecting all elements on a page. Every HTML page is built on content placed within HTML tags. Each set of tags represents an element on the page. Look at the following CSS example, which uses the universal selector:

Rohit Kumar
by Rohit Kumar , web Develoer , zombiesoftwares

class selector also use for group selection.It use to select a particular tag and apply css or java script. 

Jonathan de Flaugergues
by Jonathan de Flaugergues , software engineer , Abbeal

The class selector allows to selects elements with a specific class attribute and to define a specific style to its.

 

We use class selector instead of id selector to define a style for more than one element.Example :.my-class {  color: red;}<div class="my-class">  <div class="my-class"></div></div>

 

Both div will apply the red color style defined in the my-class selector.

 

 

 

 

 

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.