简体   繁体   English

如何设置HTML标头的文本颜色

[英]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. 我在设置类.headers中的两个标题的文本颜色时遇到麻烦。

My Headers (the periods are there because idk how to format HTML here) 我的标头(出现期间是因为idk在这里如何格式化HTML)

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

CSS 的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> . 您有两种不同的元素, <h1><h2> Your CSS is specifying <h1> elements with the class name headers . 您的CSS正在使用类名称headers指定<h1>元素。 There's two things you could try: 您可以尝试两种方法:

Create CSS class for both elements: 为两个元素创建CSS类:

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

OR, don't specify the element type in your CSS class: 或者,不要在CSS类中指定元素类型:

.headers {color: white;}

Try: 尝试:

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

or you can use your own class: 或者您可以使用自己的课程:

.headers {
   color: #YOURCOLOR;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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