Home › Forums › CSS › #id.class or #id .class › Re: #id.class or #id .class
you wouldnt use an id and a class for hooking onto the same element. that would look like this and is wrong: #id.class
but what you are asking is when to use the certain selectors.
you can have
now to hook onto that you would go: div.message – correct
or if it had a id instead of class:
div#message – correct
you can also have
now, to hook on or style this div you can only use one class, or one id per set of style rules
like this:
#message{color: red;}
or
.box{font-size: 14px;}
but not
#message.box{…}
and for the last bit
something like this: #message .title{..}
this is when there is another element with the class of title is inside the element with an id of message. that would look like this
Im some random title
i hope this helps you understand better