/    Sign up×
Community /Pin to ProfileBookmark

Could somebody explain to me what is exactly the difference between using <div class=””> and <div id=””> for positioning. It is proberly pretty simple I just can’t figure out when to id and whem to use class.

/asbjoern

to post a comment
CSS

2 Comments(s)

Copy linkTweet thisAlerts:
@AdamGundryAug 28.2004 — The basic difference is that you can have multiple classes per page, but IDs must be unique (which makes them useful for JavaScript programming, amongst other things). It's really a matter of preference; if you need to access the element with a script then you should use ID, but for simple CSS I tend to use class in case I need to reuse the same style.

Adam
Copy linkTweet thisAlerts:
@asbjoernauthorAug 28.2004 — Thanks a lot that cleared things up ?
×

Success!

Help @asbjoern 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 4.27,
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,
)...