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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12763344/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 03:12:34  来源:igfitidea点击:

removing bold styling from part of a header

html

提问by Apollo

Is there a way to remove bold styling from part of a header?

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

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

Is there a way to accomplish this?

有没有办法做到这一点?

回答by Sebass van Boxel

You could wrap the not-bold text into a span and give the span the following properties:

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

.notbold{
    font-weight:normal
}?

and

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

See: http://jsfiddle.net/MRcpa/1/

见:http: //jsfiddle.net/MRcpa/1/

Use <span>when you want to change the style of elements without placing them in a new block-level element in the document.

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

回答by GreenMatt

If you don't want a separate CSS file, you can use inline CSS:

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

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

However, as Madara's comment suggests, you mightwant to consider putting the unbolded part in a different header, depending on the use case involved.

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

回答by Anoop

Yes you can add text inside <span>and override css. jsfiddle

是的,您可以在其中添加文本<span>并覆盖 css。提琴手

html:

html:

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

css:

css:

span{
   font-weight: normal;
}

回答by Dhaval J. Patel

Better one: Instead of using extra span tags in html and increasing html code, you can do as below:

更好的一个:代替在 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> 

Here, you can use CSS as below:

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

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

You just need to use ID assigned to the respected div tag of table. I used "#sc-nav-display" with "th" in CSS, so that, every other table headings will remain BOLD until and unless you do the same to all others table head as I said.

您只需要使用分配给表的受尊重 div 标签的 ID。我在 CSS 中使用了带有“th”的“#sc-nav-display”,因此,所有其他表格标题都将保持粗体,直到并且除非您对所有其他表格标题都按照我所说的那样做。

回答by Saurav

It is super simple, By using "font" inside paragraph. An example is shown below:

超级简单,通过在段落内使用“字体”。一个例子如下所示:

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

Heading 1

标题 1

Heading 1

标题 1

回答by Mindy

<ul>
    <li><strong>This text will be bold.</strong>This text will NOT be bold.
    </li>
</ul>