Html 改变 h2 的颜色
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8684614/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
changing color of h2
提问by Night Walker
How I can change the color of h2 ?
如何更改 h2 的颜色?
I have tried <h2 color="#006699">Process Report</h2>
but it's not changed and I am still getting this default black colour
我试过了,<h2 color="#006699">Process Report</h2>
但它没有改变,我仍然得到这个默认的黑色
Thanks .
谢谢 。
回答by rekire
Try CSS:
试试 CSS:
<h2 style="color:#069">Process Report</h2>
If you have more than one h2 tags which should have the same color add a style tag to the head tag like this:
如果您有多个应该具有相同颜色的 h2 标签,请在 head 标签中添加一个样式标签,如下所示:
<style type="text/css">
h2 {
color:#069;
}
</style>
回答by Michiel van Oosterhout
If you absolutely mustuse HTML to give your text color, you have to use the (deprecated) <font>
-tag:
如果您绝对必须使用 HTML 来为文本提供颜色,则必须使用(已弃用)<font>
-tag:
<h2><font color="#006699">Process Report</font></h2>
But otherwise, I strongly recommend you to do as rekiresaid: use CSS.