8. Basic Text Formatting: Bold, Italic, and Underline
HTML offers elements to change the appearance and meaning of text. It's important to understand the difference between presentational elements (which CSS has largely replaced) and semantic elements (which convey meaning).
8.1 Semantic Text Elements (Recommended)
| Element | Purpose | Appearance (Default) |
|---|---|---|
<strong> | Indicates importance or severity. | Bold |
<em> | Indicates emphasis (stressing a word). | Italic |
html
The deadline is tomorrow. Make sure you submit the assignment on time.
I told him, "You need to stop running," but he didn't listen. I said, "You need to stop running!"
8.2 Presentation Text Elements (Use with Caution)
| Element | Purpose | Appearance (Default) |
|---|---|---|
<b> | Bold (no special importance implied). | Bold |
<i> | Italic (for technical terms, thoughts, or foreign words). | Italic |
Generally, use <strong> and <em> as they are semantically richer. If you just want text to look bold or italic without adding meaning, use CSS.