从标题的一部分删除粗体样式

Apo*_*llo 22 html

有没有办法从标题的一部分删除粗体样式?

<h1>**This text should be bold**, but this text should not<h1>
Run Code Online (Sandbox Code Playgroud)

有没有办法实现这个目标?

Seb*_*xel 43

您可以将非粗体文本包装到span中,并为span提供以下属性:

.notbold{
    font-weight:normal
}?
Run Code Online (Sandbox Code Playgroud)

<h1>**This text should be bold**, <span class='notbold'>but this text should not</span></h1>
Run Code Online (Sandbox Code Playgroud)

请参阅:http://jsfiddle.net/MRcpa/1/

使用<span>时要更改元素的风格,而不将它们放置在一个新的块级元素在文档中.


Gre*_*att 14

如果您不想要单独的CSS文件,可以使用内联CSS:

<h1>This text should be bold, <span style="font-weight:normal">but this text should not</span></h1>
Run Code Online (Sandbox Code Playgroud)

但是,正如Madara的评论所暗示的那样,您可能需要考虑将unbolded部分放在不同的标题中,具体取决于所涉及的用例.