I have a website I'm building with a header that is going to be present on all pages. However, I'd like the header to change background color depending on div that follows the header. Is there a way that I can accomplish this with just 1 css file?
header {
color: white;
background-color: red;
text-align: center;
}
<header>
<h1>header</h1>
</header>
<div id="page1">
<p>page content</p>
</div>
Here's an example of a page that might be on my website. Let's say I have another page where the page has an id "page2." How can I dynamically have the background updated based on what the id of the div is? Is this possible? If not, is there an easy workaround to accomplish the desired result?