添加颜色上的HTML按钮的部分文本 [英] Add color on parts of the text of an html button
问题描述
我有一堆HMTL按钮,有些像一个值:标题*我想明星为红色,而文本的其余部分为黑色。这可能吗?
I have a bunch of hmtl buttons, some have a value like: "Title*" I would like the star to be colored red while the rest of the text is black. Is this possible?
我发现这个code建议,以使文本彩色:
I found this code suggestions to make the text colored:
<form>
<input type="button" value="this is a styled text button" style="color:#fff;">
</form>
是这样的可能修改的价值会受到影响的文字,以便只有部分?
Is something like this possible to modify so only parts of the text in value will be affected?
推荐答案
您需要使用跨度其他甲肝建议。我会完全但避免使用内联CSS与风格
属性。相反,使用类。它很难推荐究竟如何应用CSS不知道使用的范围,但下面是一个例子:
You need to use a span as others hav suggested. I would however completely avoid using inline css with the style
attribute. Instead use classes. Its hard to recommend how exactly to apply the CSS without knowing the context of the usage but the following would be an example:
HTML
<button class="starred">Title <span>*</span></button>
CSS:
button.starred span { color: #f00; }
这篇关于添加颜色上的HTML按钮的部分文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!