Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

What a class selector is and how it’s used?

user-image
Question added by Faten Almajaly
Date Posted: 2015/05/21
Naveed Chheena
by Naveed Chheena , Prienciple Software Engineer , innokat

When ever our web page it loaded into web browser. the browser identifies the page in the shape of objects, COM Objects, DOM Objects and Window Objects.

As per your question of concern the DOM objects could be identified by tag, id or class name.

When we set the properties of an element in the document with the help of class name is called class selector. This class selector is mostly used in CSS or Scripting languages etc.

Whit the help of class select we could manipulate object properties and attributes.

mahboob khan
by mahboob khan , Project Student Information System , TekNords Inc Swat.K.P.K

.className { declaration block }

Mohamed Abdelnour
by Mohamed Abdelnour , UI/UX Specialist , DXC Technology previously known as (Hewlett-Packard Enterprise)

In the CSS, a class selector is a name preceded by a full stop (“.”) and an ID selector is a name preceded by a hash character (“#”).

Assalamu alaikum,

 

 

Class selector is used to select the elements you want to style.

 

For example,   style your name.

 

<p class="my-class-name">  murad almajaly </p>

 

p.my-class-name

{

   text-transform: uppercase;}

 

Result // MURAD ALMAJALY

///////////////////////////

 

 

Check this link for  several number selectors in css.

 

http://www.w3schools.com/cssref/css_selectors.asp

 

mossawir Ahmed
by mossawir Ahmed , Sr Frontend Web Developer , Cloud 9 Networks

simple. class is use to style a html element with css.

the usage of class is

 

<p class="para">i am a paragraph </p>

 

to target it with css and style. add a style sheet in your webpage.

 

.para {

     font-size:20px;

     color:#006699;

}

there are multiple uses of classes. you can add multiple classes in one element like

<p class"para1 para2">I am a paragraph with two classes</p>

 

you can target them like

.para1.para2 {

font-size:50px;

}

 

for more info on css and targeting elements. check w3school.com.

 

classes can also be used for selecting element and performing tasks with jquery and javascript.

HTML class base selector for example if in css you have left class .left{ text-align=left } In HTML elements mentioning class="left" will be aligned left If you want to specify to some tags then you can create class h1.left{} now only tags having this class will be aligned left

Reda Ramadan
by Reda Ramadan , Senior .Net Developer , KFS Group

class selector is a class added to an html element to be tagged and can be later selected using java script, JQuery, or even CSS.

 

see the following example:

 

// html element

<div class="personal"> </div>

 

 

 

// css style

.personal

{

    // you can add here any style rules that you want

}

// it will apply these style rules for all elements have this class.

 

// jQuery

$(".personal").hide();

// it will hides all elements with this class "personal".

 

you will find useful answer about your question at the following url:

http://stackoverflow.com/questions/9836151/what-is-this-css-selector-class-span

 

Regards,

Reda Ramadan

Faisal Raza Faisal
by Faisal Raza Faisal , Web Design Project Manager , Kat systems

Class selector is formatting in html and is defined in html page or separate in file of css and it is defined as .class

Ratandeep mokha
by Ratandeep mokha , Senior ui developer , Uplers

their are two purpose of class

1) styling the div or any element for layout purpose

2) selecting  the element  using id or class to apply jquery events n functions

others have given few examples above so i dont require to show it  again

 

Kashif Husain
by Kashif Husain , Sr. Front end Engineer , Self-Employed (Themeforest and Freelancing)

  1. In the CSS, a class selector is a name preceded by a full stop “.” and an ID selector is a name preceded by a hash character “#”. The difference between an ID and a class is that an ID can be used to identify one element, whereas a class can be used to identify more than one.

http://www.w3schools.com/cssref/sel_class.asp

 

More Questions Like This

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