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

时间:2012-10-06 19:59:11

标签: html

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

<h1>**This text should be bold**, but this text should not<h1>

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

7 个答案:

答案 0 :(得分:41)

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

.notbold{
    font-weight:normal
}​

<h1>**This text should be bold**, <span class='notbold'>but this text should not</span></h1>

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

如果要更改元素的样式而不将它们放在文档中的新块级元素中,请使用<span>

答案 1 :(得分:11)

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

<h1>This text should be bold, <span style="font-weight:normal">but this text should not</span></h1>

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

答案 2 :(得分:2)

是的,您可以在<span>中添加文字并覆盖css。 jsfiddle

HTML:

<h1>**This text should be bold**, <span>but this text should not</span><h1>

的CSS:

span{
   font-weight: normal;
}

答案 3 :(得分:2)

<h1 style="font-weight: normal;"></h1>

尝试一下?

答案 4 :(得分:0)

更好的一个:您可以执行以下操作,而不是在html中使用额外的span标记并增加html代码:

<div id="sc-nav-display">
    <table class="sc-nav-table">
      <tr>
        <th class="nav-invent-head">Inventory</th>
        <th class="nav-orders-head">Orders</th>
      </tr>
    </table>
  </div> 

在这里,您可以使用CSS,如下所示:

#sc-nav-display th{
    font-weight: normal;
}

您只需要使用分配给表的受尊重div标签的ID。 我使用&#34;#sc-nav-display&#34;用&#34; th&#34;在CSS中,所以,除非你像我说的那样对所有其他表格做同样的事情,否则每个其他表格标题都会保持粗体。

答案 5 :(得分:0)

它非常简单,在段落中使用“字体”。一个示例如下所示:

<h1>Heading 1</h1>
<p><font size="6"> Heading 1</font></p>

标题1

标题1

答案 6 :(得分:-2)

#include <iostream>
#include <vector>
#include <bitset>

using namespace std;  

int main()
try
{

   string myString = "Hello World"; // string object

   vector<bitset<8>> us;           // string to binary array of each characater

   for (int i = 0; i < myString.size(); ++i)
   {
        // After convert string to binary, push back of the array
        us.push_back(bitset<8>(myString[i]));
   }

   string c;  // binary to string object

   for (int i = 0; i < us.size(); ++i)
    {
        // the function 'to_ulong' returns
        // integer value with the same bit representation as the bitset object.
        c += char(us[i].to_ulong());
    }

    cout << c;

}
catch (exception& e)
{
    cerr << "the error is : " << e.what() << '\n';
}