HTML <mark> Tag โ Highlighted Text
๐ Introduction
The <mark> tag is used to highlight text in HTML.
By default, browsers display it with a yellow background, similar to a marker highlight.
It is commonly used to draw attention to important parts of text.
๐งฑ Syntax
<mark>Highlighted text</mark>
๐ก Example
<!DOCTYPE html>
<html>
<head>
<title>Mark Tag Example</title>
</head>
<body>
<p>This is a normal sentence.</p>
<p>This is <mark>highlighted text</mark> inside a paragraph.</p>
</body>
</html>
๐ฅ๏ธ Output Explanation
- Normal text appears regular
- Text inside
<mark>is highlighted (usually yellow background) - It visually draws attention to important content
๐ฏ When to Use <mark>
Use <mark> for:
- Search results highlighting
- Important keywords
- Showing selected or matched text
- Drawing attention to key parts
Example:
<p>Learn <mark>HTML</mark> step by step.</p>
โ ๏ธ Important Note
๐ <mark> is NOT just decoration
It has semantic meaning: it shows relevance or emphasis in context
โ๏ธ <mark> vs <strong> vs <u>
| Tag | Purpose | Appearance |
|---|---|---|
<mark> |
Highlight important text | Yellow background |
<strong> |
Important meaning | Bold |
<u> |
Underline (visual only) | Underline |
๐จ Styling <mark>
You can customize it with CSS:
<mark style="background-color: orange;">Important text</mark>
โ You can change colors, padding, etc.
๐ซ Common Mistakes
- Using
<mark>for decoration only โ - Overusing it everywhere โ
- Confusing it with
<strong>โ
๐งช Mini Exercise
Create a page with:
- A paragraph about learning HTML
- Highlight:
- The word โHTMLโ
- One important keyword in the sentence