更改< p>中一个单词的颜色标签 [英] Change color of one word in <p> tag
本文介绍了更改< p>中一个单词的颜色标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在处理html文档,并且只想在我的< p>
标记中使用一个单词来标记不同的颜色.无需制作完全不同的< p>
标签,是否可以实现?
I'm working on an html document, and want to make only one word in my <p>
tag a different color. Is this possible without making a completely different <p>
tag?
<!-- Example -->
<p>I want to make only THIS word blue.</p>
<!-- My only solution -->
<p style="display:inline;">I want to make only </p><p style="display:inline; color:blue;">THIS</p><p style="display:inline"> word blue</p>
必须有一种更好的方法.
There must be a better way of doing it.
推荐答案
为此使用 span
标记,默认情况下它是内联的:
Use a span
tag for this, it's inline by default:
<h3>A much simpler solution:</h3>
<p> I only want to make only <span style="color:blue;">THIS</span>word blue </p>
但是实际上,您通常会这样做,定义一个类并将其应用于 span
:
But actually, you would do it like this normally, defining a class and applying that to the span
:
.blue_text {
color: blue;
}
<p> I only want to make only <span class="blue_text">THIS</span>word blue</p>
这篇关于更改< p>中一个单词的颜色标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文