CSS help

ultimacloud

Senior Member
Joined
Mar 25, 2007
Messages
633
Reaction score
2
anyone know what it means when i do this :

#id .myclass .myclass2 {

my property
}

issit referring to setting .myclass2 property if so why can't we just use .myclass2{ } instead
 

davidktw

Arch-Supremacy Member
Joined
Apr 15, 2010
Messages
13,547
Reaction score
1,301
anyone know what it means when i do this :

#id .myclass .myclass2 {

my property
}

issit referring to setting .myclass2 property if so why can't we just use .myclass2{ } instead

.<classname> #<identifier>

In CSS standard,

The above would be referring to an element applied with class "myclass2" which is a descendant of a parent/ancestor element applied with class "myclass", which is also a descendant of a parent/ancestor element applied with an identifier "id"

just having ".myclass2" will fit ANY element in the whole DOM that is applied with class "myclass2".

In short, the matching is different. But the result can be the same depending on your actual DOM.
 
Important Forum Advisory Note
This forum is moderated by volunteer moderators who will react only to members' feedback on posts. Moderators are not employees or representatives of HWZ Forums. Forum members and moderators are responsible for their own posts. Please refer to our Community Guidelines and Standards and Terms and Conditions for more information.
Top