Looking through style sheets from popular & unpopular websites I have found the div
selector included in them. The bottom four examples were taken from the style sheets of the popular sites Stack Overflow, Github, Youtube & Twitter:
div.form-item-info{padding:4px 0 4px 4px;width:80%;color:#777;}
.searchFooterBox div span.smallLabel{font-size:14px}
#readme.rst div.align-right{text-align:left;}
.hentry .actions>div.follow-actions{visibility:visible;text-align:left;}
I find that I can design fully functioning CSS style sheets with out using the div
selector so the question is:
What is the div
selector's function?
&
Why do so many developers use it?
EDIT:
To be clear, when using the div
selector, what does it mean when div
appears before an id or class?
For example:
div.foo { color:black; }
div#bar { color:gray; }
And what does it mean when div
appears after an id or class?
For example:
.foo div { color:black; }
#bar div { color:gray; }
When the div
selector appears after an id or class does it have to have another selector appear after it?
For example:
#foo div span { color:black; }
#foo div p { color:black; }