/    Sign up×
Community /Pin to ProfileBookmark

Diffrence btween ID and class

Hi all…

can anyone tell me the diffrence between ID and class. Why we use both and where we use both.

I searched but all the places i got almost same answer like. Id we can use once and class we can use multiple..

But still I am wondering why to use ID and where to use how we can decide which to use

Thank you in advance

to post a comment
CSS

4 Comments(s)

Copy linkTweet thisAlerts:
@roondogMar 23.2007 — I would say use id in the first instance if you want the style applied to several different elements use class. Id can also be used in conjuction with javascript and getElementById.
Copy linkTweet thisAlerts:
@spiderauthorMar 23.2007 — Hello Thank you for your answer.

But actually I am looking for answer of a question

Q. What is Id and class

Q. Whats deferences between ID and Class

Q. Why and where we use them

Thank you
Copy linkTweet thisAlerts:
@roondogMar 23.2007 — They are used for CSS - Cascading style sheets. They are used to asign specific styles to elements in your html.

I.e

in your css you would have:

#blue{

color: blue;

}

in your html you would have:

<span id="blue">This text is blue</span>

for class you would use . instead of #

Google css tutorials and you find a better way to style your sites.
Copy linkTweet thisAlerts:
@bathurst_guyMar 23.2007 — Please search before creating a new thread. This question has been asked numerous times.
×

Success!

Help @spider spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...