/    Sign up×
Community /Pin to ProfileBookmark

#id vs. div#id ?

Hello everyone,
Can someone point out the difference between #id and div#id? I’ve notice some css that has div#id and some site don’t. Is it an inherit rule? I’m sorry but I just don’t have the time to go through all the CSS rules. OK.. I’m just lazy but I will if I have to.

Thanks,
Eugene

to post a comment
CSS

3 Comments(s)

Copy linkTweet thisAlerts:
@Lone_ReactionAug 26.2005 — No real difference if the id is used on a div. But a div#id can only be used on a div, a #id may be used for other stuff.
Copy linkTweet thisAlerts:
@NogDogAug 26.2005 — The shorter format probably has more use with classes ("div.class" vs. ".class") since a class could logically be applied to more than one type of HTML element, whereas an ID should always be used only once within your HTML, and thus should always apply to just one element type.

However, I tend to use the "#id" format a lot, I guess because I'm lazy and want to type fewer characters, plus there's less to change if I decide to change the type of HTML element for that item in my markup. (For instance, I realize I don't need it to be a DIV, it can just be a H1 element.)
Copy linkTweet thisAlerts:
@febrocksauthorAug 26.2005 — Thank you both.. I've tested it and now I understand.

I tend to use .class more then #id also but that's just the way I'd started learning css and now I'm trying to learn all the rules so I can correct the mistakes I've made. Or rather to be validated.

Have a good day..

Eugene
×

Success!

Help @febrocks 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.17,
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: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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