More Than Just Looks: The Deep Dive into Semantic Text
In the early days of the web, if you wanted text to be bold, you used <b>. If you wanted it italic, you used <i>. The web has since evolved. The most important shift in modern HTML is the focus on **semantics**: using tags to describe the *meaning* and *role* of content, not just its visual appearance.
The "Big Two": Importance vs. Emphasis
This is the most critical distinction to learn. While they may look identical in a browser, their meaning is worlds apart.
<strong>vs.<b>:<strong>marks text as having "strong importance, seriousness, or urgency." Use it for warnings, key phrases in a document, or labels that need to be understood quickly. A screen reader might use a more forceful tone for this text.<b>(Bring Attention To) is purely presentational. It makes text bold without implying any extra importance. Its use is now limited to cases where you want visual boldness *without* semantic meaning, like a product name in a review.<em>vs.<i>:<em>(Emphasis) is used to stress a word or phrase, thereby changing the meaning of the sentence (e.g., "I *really* didn't say that.").<i>(Idiomatic Text) is for text that's in a different "voice" or mood, such as a foreign word (bon appétit), a technical term, a thought, or a ship's name. It doesn't add emphasis.
**Why does this matter?** For **accessibility**, screen readers can change their intonation for `<strong>` and `<em>`. For **SEO**, search engines like Google give more weight to keywords inside `<strong>` than `<b>`.
Edits and Annotations: Showing Change
HTML provides tags specifically for marking up edits and highlights.
<del> (Deleted Text)
Renders as strikethrough. It indicates that content has been removed from the document.
<ins> (Inserted Text)
Renders as underlined. It indicates that content has been added to the document.
<mark> (Marked Text)
Renders as highlighted. It represents text that is marked or highlighted for reference, like search results on a page.
Technical & Computer-Related Text
A common point of confusion is the set of tags for displaying code and technical concepts. They each have a distinct purpose.
<code>: For a small, inline snippet of computer code. Example:document.getElementById().<pre>: For a multi-line block of pre-formatted text (usually code). It preserves whitespace (spaces and line breaks).function hello() { console.log("Hi!"); }<kbd>: For user keyboard input. Example: Press Ctrl + C.<samp>: For sample output from a computer program. Example: File not found.<var>: For a variable in a mathematical expression or programming context. Example: x + y = 10.
Typographical and Positional Text
Finally, some tags are for specific typographical conventions.
<sub>&<sup>: Subscript and superscript text. These are semantic for things like chemical formulas (H2O) and math (E = mc2).<small>: For "small print" or side comments, like copyright notices or legal disclaimers. It represents content that is less important.<abbr>: For abbreviations or acronyms. Use the `title` attribute to provide the full expansion (e.g., HTML).
Key Takeaway: Before you reach for a tag, ask "What does this text *mean*?" Is it important? Is it a code snippet? Is it a legal disclaimer? Choosing the right semantic tag makes your site more accessible, better for SEO, and easier for other developers to understand.