首页 > 解决方案 > 如何仅使用 CSS 突出显示文本中的一个特定单词?

问题描述

如何仅使用 CSS 突出显示文本中的一个特定单词?我不能在标签 p 中添加另一个标签。

<p class="header_heading">
      Some text that I need to highlight
</p> 

标签: css

解决方案


在单词周围放置一个跨度并应用于background-color跨度。

<p>
  Some text <span style="background-color: green;">that</span> I need to highlight
</p> 

推荐阅读