Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 981057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:28:50+00:00 2026-05-16T04:28:50+00:00

Looking through style sheets from popular & unpopular websites I have found the div

  • 0

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; }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:28:51+00:00Added an answer on May 16, 2026 at 4:28 am
    1. Being more explicit in your selector makes it easier to remember what the HTML structure is like. Months down the line I can read the CSS and based on my explicit rules I can automatically map the structure in my head without going back to the HTML.
    2. By specifying the node name before the class or ID, the rule becomes more specific. If you want to override .foo { color:black; } for a div that has a class of foo, just do div.foo { color:red; }. Paragraphs that have a class of foo would be black, while divs would be red.
    3. It can be useful if you want to serve different css rules based on HTML structure. In the rules below, Any span inside a div is red. Any direct span under #foo is blue.

    CSS:

    #foo div span { color:red; }
    #foo span { color:blue; }
    

    html for that:

    <div id="foo"><span>blah</span> <div><span>blah</span></div> </div> 
    

    Live demo that you can play around with: http://jsfiddle.net/6dw2r/

    EDIT:

    1. div#foo matches a div with an id of foo.
    2. div#foo div means any div descendants of #foo.
    3. No. It doesn’t.

    Please read http://www.w3.org/TR/CSS2/selector.html#pattern-matching for further questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been looking through the source code for the Flash-based Google TV example
PROBLEM SOLVED!! I just found my mistakes, after looking through the debugger over and
I am looking through code that has multiple naming conventions from multiple developers -
So I've gotten somewhat used to Javadoc style documentation. Looking through various examples of
Looking through multiple iOS crash logs, I'm finding stack traces which are near identical
Looking through decimal.py , it uses NotImplemented in many special methods. e.g. class A(object):
Looking through a few SQL implementations, I noticed that most DBMSs support defining an
Looking through the documentation for CFDataRef I can't see anything that will compress a
Looking through the massive android source code, anyone on here who know where exactly
While looking through some old code I came across this gem: MyObject o =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.