简体   繁体   English

如何更改 html 中的字体颜色

[英]how do I change font color in html

the relevant part of my code is:我的代码的相关部分是:

<p style="font-family:'impact', color:red">
            something          
</p>

The problem is I can't use both the color and the font together.问题是我不能同时使用颜色和字体。 If I use the font-family property alone, it works perfectly.如果我单独使用font-family属性,它会完美运行。 If I use the color property alone, it works perfectly.如果我单独使用color属性,它会完美运行。 But if I use both properties together, as shown above, neither of them work.但是如果我同时使用这两个属性,如上所示,它们都不起作用。

What error am I making in my inline style code?我在我的内联样式代码中犯了什么错误? What is the proper way to use the style attribute to change multiple CSS properties?使用 style 属性更改多个 CSS 属性的正确方法是什么?

Write it like that:像这样写:

<p style="font-family:'impact'; color:red"></p>

When using the style attribute to apply a unique style to a single paragraph element, you should include a semicolon after each CSS property.使用 style 属性将唯一样式应用于单个段落元素时,应在每个 CSS 属性后包含一个分号。

 <p style="color: red;"> This text is red </p> <p style="font-family: impact;"> This text is impact font </p> <p style="color: red; font-family: impact;"> This text is red and impact font </p>

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

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