0

I am working on adding some CSS to a site I am making, and have identified what I need to modify:

#MSOZoneCell_WebPartWPQ1{
background-color: #FFF !important;
outline: 4px solid white;
}
#MSOZoneCell_WebPartWPQ2{
background-color: #FFF !important;
outline: 4px solid white;
}
#MSOZoneCell_WebPartWPQ3{
background-color: #FFF !important;
outline: 4px solid white;
}

.....

#MSOZoneCell_WebPartWPQ20{
background-color: #FFF !important;
outline: 4px solid white;
}

I can't override the upper level more generic containers so that it doesn't require the different numbers. Is there a JS or other solution to my problem? I don't have the ability to edit the HTML, only the CSS.

I didn't see a similar question but I may just be using the wrong terms.

2
  • 1
    Well normally one would use a class. Without seeing HTML hard to give you solutions that do not rely on ID. Commented Jul 28, 2017 at 14:08
  • @epascarello updating OP but I lack the ability to edit the HTML on the page. Commented Jul 28, 2017 at 14:11

1 Answer 1

2

Best solution use a class or a selector that targets the element without using the id, but you can use an attribute starts with selector

[id^="foo"] {
    background-color: green;
    margin: .2rem;
}
<div id="foo1">foo1</div>
<div id="foo2">foo2</div>
<div id="foo3">foo3</div>
<div id="foo4">foo4</div>
<div id="5foo">5foo</div>
<div id="6foo6">6foo6</div>

Sign up to request clarification or add additional context in comments.

2 Comments

To clarify, [id^="foo"] will allow cause an edit on any id that starts with "foo" to receive that edit?
any id that starts with foo gets those css rules.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.