我有一个用什么来描述h6这样的标签
h6{
font-family: 'Josefin Sans', sans-serif;
font-size: 10px;
text-align: center;
color: #0f7f7f7;
text-shadow: 1px 1px 1px rgba(0,0,0,0.6);}
在我的页面中只有一行我想要一个例外,所以我这样做了:
<h6 font color="red">text here not in red <br>
但是我无法找到为什么它仍然保持颜色,CSS中定义的内容
答案 0 :(得分:3)
内联css看起来像这样
<h6 style="color:red">text here IS red </h6><br>
答案 1 :(得分:3)
请参阅此处jsfiddle
选项1:,以防您想要设置一个元素:
<h6 style="color:red">text here is in red </h6>
首先,color: #0f7f7f7;
不正确。所有颜色的HEX值都有6个字符而不是7个
第二个,您错过<h6>
中的结束标记,您始终需要使用</h6>
第三个,color
属性就是这样使用它
<font color="red">text here is in red</font>
第四个,HTML5中不支持color属性。所以在html中如果你需要改变smth使用style=""
。 <tagname style="property value">
<h6 style="color:red;font-size:20px;text-transform:uppercase"</h6>
等
选项2 :如果您要将多个项目应用于相同的样式,例如您想将color:red
添加到更多元素,那么 NOT 使用内联样式,但是为这些元素添加一个类,然后从CSS设置样式。
例如
<h6 class="red">text here is in red</h6>
<p> some text</p>
<h2 class="red">text here is in red</h2>
<p> some text</p>
<h3 class="red">text here is in red</h3>
<p> some text</p>
和CSS
.red { color:red;}
了解更多信息点击此处HTML style
答案 2 :(得分:2)
您的HTML无效。这是你如何做到的。
h6{
font-family: 'Josefin Sans', sans-serif;
font-size: 10px;
text-align: center;
color: #f7f7f7;
text-shadow: 1px 1px 1px rgba(0,0,0,0.6);
}
&#13;
<h6 style="color:red">text here is in red</h6>
&#13;
阅读有关inline-css和style
属性here的内容。
编辑:好像您的颜色的十六进制值无效。
答案 3 :(得分:0)
我认为只是语法问题。试试:
<h6 style="color:red">text here not in red <br>
答案 4 :(得分:0)
首先,您使用错误的语法来应用内联样式。 (由@grateful发布)
其次,您可以更好地设置类名并将样式应用于此类名。例如:
CSS:
h6 {
font-family: 'Josefin Sans', sans-serif;
font-size: 10px;
text-align: center;
color: #0f7f7f7;
text-shadow: 1px 1px 1px rgba(0,0,0,0.6);
}
h6.important-note {
color: red;
}
HTML:
<h6>A normal heading of size six.</h6>
<h6 class="important-note">A really important heading of size six.</h6>
答案 5 :(得分:0)
更好用:
<h6 style="color:#ff0000">text here IS red </h6>