I want to create a few span-elements within a p-element. These span-elements should have different background colors than the p-elements.
The code:
<p style="background-color:blue"> <!-- color not working -->
<span style="background-color:red"><H2>boo-title</H2> <!-- color not working -->
<script language="JavaScript">
document.write("boo");
</script>
</span>
<span style="background-color:green"><H2>foo-title</H2> <!-- color working -->
<script language="JavaScript">
document.write("foo");
</script>
</span>
</p>
Why is the background-color sometimes working and sometimes not, although it is defined in the same way? And how do i get this to work, when defining it like this?