简体   繁体   中英

How To Set Text Colour of HTML Headers

Im starting to build my first website for a class at my school. I was having trouble setting the text colour of my two headers in the class .headers.

My Headers (the periods are there because idk how to format HTML here)

<h1 align="center" class="headers">All Hail our Eternal Leader</h1>
<h2 align="center" class="headers">Senpai Gabe is with us</h2>

CSS

h1.headers {color: white;}

Try like this :

h1 {
        color: white;
    }
        h2{
            color: white;
        }

or

.headers  {
        color: white;
    }

You have two different kinds of elements, <h1> and <h2> . Your CSS is specifying <h1> elements with the class name headers . There's two things you could try:

Create CSS class for both elements:

h1.headers, h2.headers {color: white;}

OR, don't specify the element type in your CSS class:

.headers {color: white;}

Try:

h1 {
   color: #YOURCOLOR;
}
h2 {
   color: #YOURCOLOR;
}

or you can use your own class:

.headers {
   color: #YOURCOLOR;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM