HTML Formatting: Beautifying Your Web Pages

Introduction

Hello, aspiring web developers! Today, we're going to dive into the exciting world of HTML formatting. As your friendly neighborhood computer teacher, I'm here to guide you through this journey step by step. Remember when you first learned to write? Well, HTML formatting is like learning to make your writing look pretty and organized. Let's get started!

HTML - Formatting

What is the use of HTML formatting?

HTML formatting is all about making your web pages look good and easy to read. It's like dressing up your content for a party! Here's why it's important:

  1. Improved readability: It helps your visitors quickly scan and understand your content.
  2. Emphasis: You can highlight important information to catch the reader's eye.
  3. Structure: It gives your content a clear, organized structure.
  4. Aesthetics: It makes your web pages visually appealing.

HTML Formatting Tags

Now, let's look at the tools we have in our HTML formatting toolbox. These are special tags that help us style our text. Here's a table of the most common HTML formatting tags:

Tag Description
<b> Makes text bold
<strong> Emphasizes text (usually bold)
<i> Makes text italic
<em> Emphasizes text (usually italic)
<mark> Highlights text
<small> Makes text smaller
<del> Shows deleted text
<ins> Shows inserted text
<sub> Makes text subscript
<sup> Makes text superscript

HTML Formatting Tags with Examples

Let's roll up our sleeves and see these tags in action!

1. Bold Text

<p>This is <b>bold</b> text.</p>
<p>This is also <strong>bold</strong> text.</p>

Output: This is bold text. This is also bold text.

The <b> tag simply makes text bold, while <strong> implies that the text is important. They look the same, but search engines might treat them differently.

2. Italic Text

<p>This is <i>italic</i> text.</p>
<p>This is also <em>emphasized</em> text.</p>

Output: This is italic text. This is also emphasized text.

Similar to bold, <i> just makes text italic, while <em> implies emphasis. They look the same but have different semantic meanings.

3. Highlighted Text

<p>This is <mark>highlighted</mark> text.</p>

Output: This is highlighted text.

The <mark> tag is like using a highlighter on your screen. It's great for drawing attention to specific parts of your text.

4. Small Text

<p>This is normal text. <small>This is small text.</small></p>

Output: This is normal text. This is small text.

The <small> tag is perfect for things like copyright notices or fine print.

5. Deleted and Inserted Text

<p>I love <del>pizza</del> <ins>salad</ins>.</p>

Output: I love pizza salad.

These tags are great for showing changes in your text. <del> shows deleted text (usually with a strikethrough), and <ins> shows inserted text (usually underlined).

6. Subscript and Superscript

<p>H<sub>2</sub>O is water.</p>
<p>2<sup>3</sup> equals 8.</p>

Output: H2O is water. 23 equals 8.

<sub> and <sup> are perfect for mathematical or chemical formulas.

Combining Formatting Tags

Here's a fun fact: you can combine these tags for more complex formatting. Let's try an example:

<p>The <strong><em>most important</em></strong> thing to remember is to <mark>have fun</mark> while coding!</p>

Output: The most important thing to remember is to have fun while coding!

See how we combined <strong> and <em> to make text bold and italic at the same time?

Conclusion

And there you have it, folks! You've just taken your first steps into the world of HTML formatting. Remember, these tags are like the spices in your cooking – use them wisely to enhance your content, not overpower it.

As we wrap up, here's a little story from my teaching experience: I once had a student who went a bit overboard with formatting. Their webpage looked like a rainbow had a fight with a bold machine! We had a good laugh about it, and it taught us all an important lesson about moderation in design.

Practice using these tags, experiment with different combinations, and most importantly, have fun! In our next lesson, we'll dive into more advanced HTML topics. Until then, happy coding!

Credits: Image by storyset