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

  • Home
  • SEARCH
  • 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 1049617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:38:43+00:00 2026-05-16T16:38:43+00:00

Given <div class=foo> <span class=bar></span> </div> I’ve always defined the CSS classes as: .foo

  • 0

Given

<div class="foo">
    <span class="bar"></span>
</div>

I’ve always defined the CSS classes as:

.foo
{

}
.bar
{

}

Is specifying the object important, or ultimately for readability so you can quickly see which sort of element you are searching for when editing? IE:

div.foo
{

}
span.bar
{

}
  • 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-16T16:38:44+00:00Added an answer on May 16, 2026 at 4:38 pm

    It will be important for element specificity.

    .foo targets any element that has a class of "foo".

    div.foo targets only <div>s that have a class of "foo". That means other elements with that class aren’t selected.

    If you’re sure only one kind of element will ever bear a given class, I guess there’s nothing wrong with prefixing the class selector with the element name for readability, or leaving it out completely if you’re lazy to type.

    However, if you think other elements might bear this class — for instance if it’s a pretty generic name like left, larger-font or sep, it’s a good idea to do this so you’re sure you’re styling the right elements.

    If there are any common styles shared by any elements with a given class, you specify just the class selector and add the common styles there, then after that specify any styles that pertain to each individual element. For example:

    .foo { /* Generic styles for foo class */ }
    div.foo { /* Styles for <div>s with foo class */ }
    blockquote.foo { /* Styles for <blockquote>s with foo class */ }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 529k
  • Answers 529k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It is possible that you are running into an issue… May 16, 2026 at 11:09 pm
  • Editorial Team
    Editorial Team added an answer Set what region? The region just for your app? The… May 16, 2026 at 11:09 pm
  • Editorial Team
    Editorial Team added an answer As a general rule, there should be no practical difference… May 16, 2026 at 11:09 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

Given the following mark-up... <div id=Header> <a href=# class=Highlight>foo</a> </div> And the following stylesheet...
Consider the following HTML: <div class=foo id=obj> I should be changed red <div class=bar
HTML: <div class=foo>firstBar</div><!-- give this one a different style --> <div class=foo>secondBar</div> <div class=foo>thirdBar</div>
Given: require 'rubygems' require 'nokogiri' value = Nokogiri::HTML.parse(<<-HTML_END) <html> <body> <p id='para-1'>A</p> <div class='block'
Given: <div class=subMenu> <a href=products.aspx class=subLink>Products</a> <a href=productCats.aspx class=subLink>Categories</a> <a href=example.aspx class=subLink>Another</a> </div> In
Given: <div class=subHead>Stock Options</div> <table class=settingTable> <tr> <td colspan=2><b>Limited Stock</b></td> </tr> <tr> <td width=50
Given a DIV with this general structure (class=post, from an extracted message board post)
So let's say I have the following in 'foo.css': .border { border : solid
Lots of div and classes name are being used in the code. http://www.csszengarden.com/ Is
Normally I would create an element in jQuery like this $('<div id=errors class=red></div>') Can

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.