If I write the same block of code below but don't include the "body" element (which also doesn't appear to do anything) then my h1 text stays black. Why is this happening? If I understand correctly, I should be able to add the h1 portion and it should change colors right?
edit: I want to clarify that I'd like to exclude the "body" portion, and want to understand why I can't. As another example, I previously had size settings for the image in the code. When I placed these settings before the h1 portion, h1 changed colors. If h1 was after, then it stayed black again.
<style>
body{
color: pink;
}
h2{
color: blue;
}
</style>
<h1 id="title" class="title">Katherine Johnson</h1>
<div id="img-div">
<img id= "image" src="https://www.nasa.gov/sites/default/files/thumbnails/image/26646856911_ca242812ee_o_1.jpg" alt="Katherine Johnson" class="center">
<h2 id="tribute-info"><ul> <li>Born in White Sulphur Springs, West Virginia, in 1918, her intense curiosity and brilliance with numbers vaulted her ahead several grades in school.</li> </li>By 13, she was attending the high school on the campus of historically black West Virginia State College. </li> <li>At 18, she enrolled in the college itself, where she made quick work of the school’s math curriculum and found a mentor in math professor W. W. Schieffelin Claytor, the third African American to earn a PhD in mathematics. </li> <li>She graduated with highest honors in 1937 and took a job teaching at a black public school in Virginia. </li> </ul></h2>
<a id="tribute-link" target="_blank" href="https://www.nasa.gov/content/katherine-johnson-biography"> Learn more about Katherine here</a>
</div>
question from:
https://stackoverflow.com/questions/65650503/what-am-i-missing-font-color-in-css 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…