The forums ran from 2008-2020 and are now closed and viewable here as an archive.
Home › Forums › CSS › [Solved] what's difference between these selectors ?
I am using the following
#selector or .selector
but when i download and template or other works i find them using these
tagName #parent .selector what’s diff between two method ?
tagName #parent .selector
isn’t my method 100% true ?
#selector or .selector will usually be enough.
There should never be a need for tagName#selector (eg. div#header) because the # is an ID and should be unique on the page.
You might occasionally see div.selector but this usually only where the class is quite general and could be applied to multiple element types.
So div.selector would apply only to divs with that class but .selector would apply to ANY element with that class whether is was a div or not.
thx very much for ur sharing ,
ans what’s diff between theses also
.selector.selector and .selector .selector
.class1.class2 selects an element that has both classes.
.class1 .class2 selects an element with a class of .class2 that is a child of an element that has a class of .class1.