Book Top Rank with Contact Details visibility for your Business, Profession, Products or Services

How do you Highlight Text in HTML CSS

Question by Saravana s On 04 September 2022, 13:29:23

(Page Views: 160)

Answer by Saravana s On 04 September 2022, 13:30:52

What is the highlighted text?

It means highlighting an important word in a paragraph or sentence. For example, This is a dangerous place, if you highlight “dangerous” in this sentence, the user will quickly see the highlighting word. And if you have a shopping website, if you highlight all the words like the ‘offer! offer!’, ‘discount’, ‘buy1 get1’, users will see that highlighting a word and read your paragraph completely. This way we can highlight important words. We can highlight the words using paired <mark> tags in HTML and background-color properties in CSS. Let’s see how to do it with an example.

How to highlight text in HTML

<p>This is an example text for <mark>highlighting</mark></p>

Output:

In the above HTML code, there is some text inside a <p> tag and only the “highlighting” text is inside the <mark> tag. Every word we put in the <mark> tag is highlighted and the default color of the mark tag is yellow. For this, you need to use the background-color property in CSS to change the color. It is one of the easiest ways to highlight the text.

How to highlight text in CSS

<p>Don't forget to buy
<span style="background-color:yellow">milk</span>today. </p>

Read more>>