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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T18:35:12+00:00 2026-05-28T18:35:12+00:00

For example, I want to do something on the first <li class=first> of a

  • 0

For example, I want to do something on the first <li class="first"> of a <ul> list.

and I write the CSS:

ul .first{
    /*awesome code here*/
}

But then, I also want to give a particular CSS to the first <p class="first"> of my <div id="content">.

and I do it like this:

#content .first{
    /*awesome code here*/
}

In case you didn’t noticed, I reused the class first to give totally different styles to two totally different cases.

  • Is it bad to reuse classes in this way?
  • Is there any possibility that this lead to glitches/bugs?
  • 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-28T18:35:13+00:00Added an answer on May 28, 2026 at 6:35 pm

    It’s fine by me because when you are intentionally defining what the first item and paragraph of your structure will look like. Although, it’d be better if you used :first-child pseudo selector but then again both will have different styles because that’s what you want.

    I hope I’m not missing the big picture here but I’m also wondering what you meant with code reusability in this case?

    If you are going to use ul.first then you have to change your

    <li id="first" to <li class="first"

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

Sidebar

Related Questions

I want to rewrite from http://example.com/blah/<something>/<somethingelse> to http://<something>.example.com/<somethingelse> , but only if the request
I am using Entity Framework 4.1 code first . Here is my Category class:
Ideally I want a function something like the following (this example doesn't compile): void
For example, I want to draw something directly to an UIView. I need an
For example I want to be able to programatically hit a line of code
I have created a separate class (let's call it class2.cs for example) and want
I have the following code in controllers/list.php: <?php class List extends Controller { function
So here's a contrived example of what I want to have improved or confirmed.
To illustrate my point, here an example: abstract class Wrapper[A](wrapped: A) { protected def
example: I want to see if array[5] holds a value or is empty.

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.