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 4107428
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:30:40+00:00 2026-05-20T21:30:40+00:00

this more a conceptual question. Recently i found myself to be more confident with

  • 0

this more a conceptual question. Recently i found myself to be more confident with this kind of html (example)

<div id="mainCont">
  <div id="mainContFirst">Text <span id="mainContFirstSpan">option</span></div>
  <div id="mainContSecond">Other Text</div>
</div>

Having all important tag marked with an ID you can easly write down css:

#mainContFirst {} etc

is this a bad pratice? Should I use just css selector? Is this faster then use selector?

Thanks

Grouping (edit)

Ok now What about elements that should have the same style?

let’s say for example in every divs the second <span> should have font-size:10px; it’s better this:

<div>
   text text <span></span> <span id="firstDivSpan"></span>
</div>
 <div>
   text text <span></span> <span id="secondDivSpan"></span>
</div>

and then the css:

#firstDivSpan, #secondDivSpan {...}

Or like this?

 <div>
   text text <span></span> <span id="firstDivSpan" class="commonStyle"></span>
</div>
 <div>
   text text <span></span> <span id="secondDivSpan" class="commonStyle"></span>
</div>

.commonStyle{...}

What’s better?

  • 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-20T21:30:40+00:00Added an answer on May 20, 2026 at 9:30 pm

    ID selectors are the fastest. That is not bad practice at all; you’re simply operating under the assumption that there will only be one element with that ID on your pages.

    That said you shouldn’t abuse IDs for lame reasons like rendering performance. Use IDs to mark truly unique elements, not to mark everything so you can forget about stuff like descendant combinators, classes, groups etc. Those other selectors are what make CSS so powerful, not just the ID selectors.

    Re question edit: there isn’t any better one in this case. Performance issues aside (because they don’t matter at all) it largely depends on the meaning of the selectors.

    If your styles apply to any element with the .commonStyle class then use the class selector. If you only want to target those two specific spans regardless of the class then the ID selectors are more appropriate.

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

Sidebar

Related Questions

I have an interesting situation here this time. This more of a conceptual question,
This is more of a conceptual question than anything. I have a base class
This is more of a conceptual question. If it helps, lets say it falls
This is more a conceptual question. Here is my current predicament; I am writing
This is more of a conceptual question than an actual implementation and am hoping
EDIT : this question is very similar to this one but it's more conceptual
This is more of a conceptual question concerning the built in functionality of PHP
this is more of a conceptual question. Is it aceptable/good programming mixing do/while loops
This is more like a conceptual question. When to use Model Binding (in ASP.NET
So this question is not so much technical but more sort of conceptual. I

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.