While I was doing CSS for a page I found that when I used to do div#myid then my CSS is applied to element and when I did div #myid it did not apply, but I don’t think its a wrong, I have used it many times and it works.
Here below my CSS is correct but still first styling does not work and second works.
I have put a sample on fiddle here is the link http://jsfiddle.net/bipin000/FnzNm/
table #tt
{
background-color:#ccc;
}
table#tt
{
color:yellow;
}
<table id="tt">
<tr><td>this is atable</td></tr>
</table>
div#myidapplies to adivelement withidset tomyid#myidapplies to ANY element withidset tomyidIt works fine with both
div#myidand#myid:SEE DEMO
As for your tables there is difference between these two
table #ttandtable#tt. The space character plays important role here.The
table #ttmeans an element withidset tottinside thetableelement at any nested level whereastable#ttmeans atablewithidset to#tt.Examples:
table #ttmay mean any of these:So just any element with
idset tottinsidetable.The
table#ttonly means this: