HTML Text Formatting — Interview Questions & Answers
Physical (Presentational) vs Logical (Semantic) Tags
Ques: What are text formatting tags in HTML?
Ans: They are tags used to style or emphasize text — for example <b>, <i>, <strong>, <em>, <u>.
Ques: What is the difference between physical and logical tags?
| Type | Meaning | Example | Purpose |
|---|---|---|---|
| Physical (Presentational) | Only visual style – how text looks | <b>, <i>, <u> | Not semantic; used for appearance |
| Logical (Semantic) | Adds meaning to text | <strong>, <em>, <mark> | Helps browsers and screen readers understand importance |
Common Formatting Tags
Ques: What is the difference between <b> and <strong>?
Ans: <b> makes text bold (visually), while <strong> indicates importance (semantic meaning).
Ques: Difference between <i> and <em>?
Ans: <i> italicizes text without meaning; <em> emphasizes text semantically.
Ques: What is <mark> used for?
Ans: Highlights text as if marked with a highlighter.
<p>This is <mark>important</mark> text.</p>
Ques: Difference between <del> and <ins>?
Ans: <del> shows deleted text (strikethrough); <ins> shows inserted text (underlined).
Ques: How are <sup> and <sub> used?
Ans: For superscript and subscript text:
E = mc<sup>2</sup> and H<sub>2</sub>O
HTML Entities and Symbols
Ques: What are HTML entities?
Ans: They represent reserved characters or symbols that can’t be typed directly in HTML.
Ques: Give some common HTML entities.
| Symbol | Entity | Description |
|---|---|---|
< | < | Less than sign |
> | > | Greater than sign |
& | & | Ampersand |
© | © | Copyright |
® | ® | Registered trademark |
| Non-breaking space |
Ques: Why use ?
Ans: To insert extra spaces that the browser won’t collapse.
Emojis in HTML (UTF-8)
Ques: How can you add emojis in HTML?
Ans: By using UTF-8 character encoding and emoji codes.
<meta charset="UTF-8">
<p>😊 🚀 🔥</p>
Ques: Why is <meta charset="UTF-8"> important for emojis?
Ans: It ensures the browser interprets the page in Unicode, allowing emoji and non-English characters to render correctly.
Advanced Formatting Concepts
Ques: How can you make text appear as code in HTML?
Ans: Use <code> for inline code and <pre> for preformatted blocks.
<pre><code>console.log("Hello");</code></pre>
Ques: How do you add quotes within text?
Ans: Use " for double quotes or the <q> tag for inline quotations.
Ques: Can CSS replace all text formatting tags?
Ans: Yes, for presentation (<b>, <i>), but semantic tags (<strong>, <em>) should still be used for meaning.
