英文:
How to add color to some words in a text in html?
问题
例如,我想为电话和电子邮件添加颜色=红色,用<strong>...</strong>括起来。看起来我不能使用嵌入的<p style=...>来添加颜色。如果我不使用CSS,我如何直接为其添加颜色?
<p>要预约,请致电Martin,电话:<strong>xxx-xxx-xxxx</strong>或发送电子邮件至<strong>support@test.com</strong>。</p>
英文:
For example, I want to add color=red to the phone and email, enclosed by <strong>...</strong>. It seems I can't use an embedded <p style=...> to add color. If I don't use CSS, how can I directly add color to it?
<p>For appointment, please call Martin at <strong>xxx-xxx-xxxx</strong> or email at <strong>support@test.com.</strong></p>
答案1
得分: 1
如果你不“想”使用CSS,“font”似乎有一个颜色属性...
<p>要预约,请致电Martin,电话号码为<strong><font color="red">xxx-xxx-xxxx</font></strong>或发送电子邮件至<strong><font color="blue">support@test.com</font></strong>。</p>
告诉我们为什么你不想使用CSS?
英文:
If you don't "want" to use css, "font" seems to have a color property...
<p>For appointment, please call Martin at <strong><font color="red">xxx-xxx-xxxx</font></strong> or email at <strong><font color="blue">support@test.com</font></strong>.</p>
Tell us why you don't want to use css?
答案2
得分: 0
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<p>要进行预约,请致电马丁,电话号码为 <strong style="color:red">xxx-xxx-xxxx</strong> 或发送电子邮件至 <strong style="color:red">support@test.com.</strong></p>
<!-- end snippet -->
如果需要,您可以在HTML元素的style属性中添加其他样式属性,用分号;
分隔。
英文:
You can use inline-styling for this purpose
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<p>For appointment, please call Martin at <strong style="color:red">xxx-xxx-xxxx</strong> or email at <strong style="color:red">support@test.com.</strong></p>
<!-- end snippet -->
If you want you can add additional styling properties in style attribute of HTML Element by separating properties with ;
答案3
得分: 0
你可以使用<style>
元素来使用CSS,而不必引用另一个CSS文件。
<style>
.redtext {
color: red;
}
</style>
<p>要预约,请致电Martin,电话号码为<strong class="redtext">xxx-xxx-xxxx</strong>,或发送电子邮件至<strong class="redtext">support@test.com。</strong></p>
英文:
You can use a <style>
element to use CSS without referencing another CSS file.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-html -->
<style>
.redtext {
color: red;
}
</style>
<p>For appointment, please call Martin at <strong class="redtext">xxx-xxx-xxxx</strong> or email at <strong class="redtext">support@test.com.</strong></p>
<!-- end snippet -->
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论