In jQuery whenever I encounter something like this:
$("div#MyDiv").....
I generally say to the developer: "Don't bother putting the div in front of #MyDiv, ID selectors are the fastest." I.e.
$("#MyDiv")....
This is because the latter will hook directly into document.getElementById rather than having to scan the DOM for all <div> elements first.
My question is, do the same rules apply to CSS selectors? I.e. rather than:
div#MyDiv
{
}
Is it faster to have simply?:
#MyDiv
{
}
(I realise that CSS selectors are incredibly fast anyway, so in reality neither would make a significant difference.)
Many Thanks
EDIT
Any links, or references might be useful for the purposes of this discussion. Thanks :-)