Weekly Webtips
Published in

Weekly Webtips

How to Highlight Text in HTML?

Hello everyone, Today in this post I will tell you how you can highlight text in HTML. So set tight and grab a cup of coffee.

To highlight text in HTML we need to wrap that piece of text in <mark> tag.

The <mark> HTML element represents text which is marked or highlighted for reference or notation purposes, due to the marked passage's relevance or importance in the enclosing context.

Let’s see at the example below:

<body>
<p>This is a sample <mark> paragraph </mark> </p>
</body>

The text “paragraph” will be highlighted because it is inside the<mark> tag.

By default the highlighted color is yellow, but don’t worry we can change it from CSS like below:

mark{
background-color:green;
}

The <mark> tags can be useful but only for content that you control. If you want to let users make their own highlights, using <mark> can potentially break the markup.

I hope so you liked it, show some love and support in the comments below.

Connect with me on Twitter

Happy Coding…..

--

--

--

Explore the world of web technologies through a series of tutorials

Recommended from Medium

containers vs virtual machine — What is the Battle All About?

Downloading and Installing Unity — For Beginners

Perform various OSINT techniques with DataSploit

Salesforce to Salesforce Integration using Named Credentials

Time and Time Zone Headaches! (JS and more)

Extra Strength Methods.

JWT authorization in Flask

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Hilal Ahmad

Hilal Ahmad

A Software Engineer with 3 years of experience in Software development. Visit me at https://about.me/hilalahmad

More from Medium

Flexbox: Exercises

Styling with Chrome Developer Tools!!

Simplifying Web development by mocking API response

How to become a Full Stack Developer?