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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:40:43+00:00 2026-05-12T06:40:43+00:00

I use the following code on my page: <div id=itemstable class=item_type1> …other divs here…

  • 0

I use the following code on my page:

<div id="itemstable" class="item_type1">
...other divs here...
</div>

And in my CSS file I have this code:

.item_type1 div {
    background-image: url(images/type1.giff);
}

the problem is there are a lot of different item types so I will need to have a lot of lines in my CSS file. I was wondering how to apply the background-image: url(images/type1.giff); style to the nested divs without assigning it to each one. eg. I want to change the code for the “itemstable” div so that it applies a css rule to the nested divs.

Is this possible?

EDIT: I’m looking for something like this:

<div id="itemstable" style="SET BACKGROUND IMG FOR NESTED DIVS HERE">
...other divs here...
</div>
  • 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-12T06:40:44+00:00Added an answer on May 12, 2026 at 6:40 am

    (If I’m understanding the question correctly:)

    Think about using a different ID/class scheme. I don’t know about the further specifics of your structure, but id="itemstable" class="item_type1" seems slightly redundant to me. Can itemstable be anything else than item_type1? Try to apply more generic class names and keep the specific cases for IDs.

    Failing that, you can add another class that is responsible for adding the background image: class="item_type1 item_types".

    EDIT

    Since it seems sheer mass is the main problem (not applying the style as the title suggests) it’s probably best to dynamically insert a style in the page header. Something along the lines of:

    <head>
        ...
        <style type="text/css" media="screen">
            <?php echo "#$myelement"; ?> div { background: url(<?php echo $image; ?>) ...; }
        </style>
    </head>
    

    Inline styles can only apply to the element directly, not one of its children. I.e.:

    <div style="background: ...;">
    

    The background only applies to this one div.
    You can’t use selectors in inline styles like:

    <div style="div { background: ...; }">
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following ASP.NET code: <div id=panelIssue runat=server style=width: 450px; height: 320px;> <gsl:IssueUC
I use the following code to hide and show a box on a bunch
In the following code the first and second images with anchors have links and
I have the following ASPX code: <asp:ScriptManager ID=ScriptManager1 runat=server /> <asp:UpdatePanel runat=server ID=UpdatePanel UpdateMode=Conditional>
I have a page that loads a div from another page on successful submission
I have div which it is hidden by default , when the use clicks
I used the following example to display a website in an iframe on my
I have this situation where i want to call a certain element depended on
Is is possible to update an image on an HTML page using the response
I use several jquery ui dialogs in my application to collect input from users

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.