Cover Image for How to Highlight text in Html
70 views

How to Highlight text in Html

To highlight text in HTML, you can use the <mark> tag or apply CSS styles to the text. Here are two methods you can use:

  1. Using the <mark> tag:
HTML
<p>This is a <mark>highlighted</mark> text.</p>

The <mark> tag is specifically designed to highlight or mark text. It typically applies a yellow background color to the enclosed text, making it stand out.

  1. Using CSS styles:
HTML
<p>This is a <span style="background-color: yellow;">highlighted</span> text.</p>

In this method, you wrap the text with a <span> tag and apply the desired CSS style using the style attribute. In this case, we set the background color to yellow using the background-color property.

You can adjust the CSS styles or use other CSS properties to customize the appearance of the highlighted text, such as changing the background color, font color, font weight, or adding a border.

Note that the <mark> tag and CSS styles may produce similar visual effects, but the <mark> tag has semantic meaning and is specifically intended for marking or highlighting text, while CSS styles provide more flexibility and customization options. Choose the method that best suits your requirements.

YOU MAY ALSO LIKE...

The Tech Thunder

The Tech Thunder

The Tech Thunder


COMMENTS