Course Content
Introduction to HTML
In this introductory module, you'll learn what HTML is and its role in web development. You will set up your development environment and create your first HTML page. You'll also understand the basic structure of an HTML document and get familiar with fundamental HTML elements and attributes.
0/4
Working with Text in HTML
This module covers how to format text in HTML, including creating headings, paragraphs, and lists. You'll learn how to emphasize text with bold, italics, and underline, and how to create links for navigation. You'll also explore text alignment and introduce inline CSS for basic styling.
0/4
Working with Images and Multimedia
In this module, you’ll learn how to add images and multimedia to your HTML pages. You'll master the <img> tag, and understand how to work with attributes like src and alt. Additionally, you'll discover how to embed audio and video files directly into your webpage, enhancing its interactivity.
0/3
Tables and Forms in HTML
This module introduces the use of tables for displaying structured data and forms for collecting user input. You'll learn how to create, format, and style tables, and how to build forms with input fields, checkboxes, and buttons. Basic HTML5 form validation will also be covered.
0/2
HTML5 Elements and Semantic Markup
Explore the power of HTML5 in this module, where you’ll learn about new HTML5 elements like <article>, <section>, and <nav>. You’ll gain an understanding of semantic HTML, which helps improve search engine optimization (SEO) and accessibility. You’ll also be introduced to HTML5-specific features such as video and audio embedding.
0/3
Advanced HTML Concepts
This module dives deeper into advanced HTML topics, including embedding external content using [iframe], working with HTML5 APIs like geolocation, and implementing accessibility best practices with ARIA attributes. You’ll also get a primer on responsive web design with the use of meta tags and media queries.
0/4
HTML Best Practices
Learn the best practices for writing clean, maintainable, and accessible HTML. This module covers proper code formatting, the importance of semantic HTML, and how to structure your HTML for SEO. You’ll also get practical tips on debugging HTML and using online validators to ensure your code is error-free.
0/3
Project – Building a Simple Website
Apply everything you’ve learned by creating a complete website from scratch in this hands-on project. You’ll plan, design, and build a multi-page website, incorporating text, images, forms, and navigation. This project will help you solidify your skills and showcase your work.
0/4
Conclusion and Next Steps
In the final module, you'll review the key concepts and skills you’ve learned throughout the course. You’ll also get guidance on the next steps in your web development journey, including an introduction to CSS for styling and JavaScript for interactivity. You’ll complete a final assessment to demonstrate your new HTML skills.
0/2
Complete HTML Course (Free)
About Lesson

 

Text Formatting

This lesson introduces HTML text formatting techniques. You’ll learn how to style and emphasize text using a variety of HTML elements, making your content visually appealing and easier to read.


1. What is Text Formatting in HTML?

Text formatting refers to altering the appearance of text to highlight important parts or add stylistic emphasis. HTML provides several elements to format text for specific purposes.


2. Common HTML Formatting Elements

  1. Bold Text: <b> and <strong>

    • <b>: Displays text in bold for visual emphasis, but does not add semantic importance.
      <b>This text is bold.</b>
      
    • <strong>: Displays bold text while adding semantic importance, signaling the content is crucial.
      <strong>This text is important and bold.</strong>
      
  2. Italicized Text: <i> and <em>

    • <i>: Italicizes text for visual styling without adding semantic emphasis.
      <i>This text is italicized.</i>
      
    • <em>: Italicizes text while indicating emphasis or importance.
      <em>This text is emphasized and italicized.</em>
      
  3. Underlined Text: <u>

    • Underlines text, typically for stylistic emphasis.
      <u>This text is underlined.</u>
      
  4. Strikethrough Text: <s> and <del>

    • <s>: Strikes through text for stylistic purposes, indicating outdated or irrelevant content.
      <s>This text is no longer relevant.</s>
      
    • <del>: Indicates deleted content, often used in collaborative editing.
      <del>This text has been removed.</del>
      
  5. Superscript and Subscript: <sup> and <sub>

    • <sup>: Displays text as superscript, often for exponents or footnotes.
      x<sup>2</sup> + y<sup>2</sup> = z<sup>2</sup>
      
    • <sub>: Displays text as subscript, often for chemical formulas or indices.
      H<sub>2</sub>O (water)
      
  6. Monospace Text: <code> and <pre>

    • <code>: Represents code snippets in a monospace font.
      <code>console.log('Hello, world!');</code>
      
    • <pre>: Preserves whitespace and formatting, often used for displaying code blocks.
      <pre>
      function greet() {
          console.log("Hello, World!");
      }
      </pre>
      
  7. Highlighted Text: <mark>

    • Highlights text with a background color, drawing attention to it.
      <mark>This text is highlighted.</mark>
      
  8. Small Text: <small>

    • Displays smaller text, often for fine print or disclaimers.
      <small>This is a small disclaimer text.</small>
      
  9. Quotations: <q> and <blockquote>

    • <q>: For inline quotations.
      <q>The quick brown fox jumps over the lazy dog.</q>
      
    • <blockquote>: For longer, block-level quotations.
      <blockquote>
          "The only limit to our realization of tomorrow is our doubts of today."
      </blockquote>
      
  10. Abbreviations: <abbr>

    • Indicates an abbreviation, with a title attribute explaining its meaning.
      <abbr title="World Wide Web">WWW</abbr>
      

3. Example: Combining Formatting Elements

<!DOCTYPE html>
<html>
<head>
    <title>Text Formatting Example</title>
</head>
<body>
    <h1>Welcome to HTML Text Formatting</h1>
    <p>This is a <strong>bold</strong> and <em>italicized</em> example of formatted text.</p>
    <p>You can write equations like: E = mc<sup>2</sup> or H<sub>2</sub>O.</p>
    <p>For code snippets: <code>console.log('Hello, World!');</code></p>
    <blockquote>
        "Good design is obvious. Great design is transparent."
    </blockquote>
    <p><mark>Highlighted text</mark> draws attention.</p>
    <p>Use <abbr title="Hypertext Markup Language">HTML</abbr> to build your webpage!</p>
</body>
</html>

4. Best Practices for Text Formatting

  1. Use Semantic Elements:
    Prefer <strong> and <em> over <b> and <i> to convey meaning as well as style.

  2. Avoid Overuse:
    Excessive formatting can make text appear cluttered. Use formatting sparingly for clarity.

  3. Maintain Accessibility:
    Use attributes like title in <abbr> and <blockquote> to provide context for users with assistive technologies.

  4. Combine Elements:
    Use combinations (e.g., bold and italic) judiciously to enhance emphasis without overcomplicating the content.


5. Hands-On Activity: Text Formatting

  1. Open your text editor and create a new file called text_formatting.html.
  2. Write the following code:
    <!DOCTYPE html>
    <html>
    <head>
        <title>HTML Text Formatting</title>
    </head>
    <body>
        <h1>Learn Text Formatting</h1>
        <p><strong>Bold</strong> and <em>Italic</em> text are great for emphasis.</p>
        <p>Highlight important content using <mark>highlighted text</mark>.</p>
        <p>Here’s an equation: x<sup>2</sup> + y<sup>2</sup> = z<sup>2</sup></p>
        <p>Example of a blockquote:</p>
        <blockquote>
            "The journey of a thousand miles begins with one step." - Lao Tzu
        </blockquote>
    </body>
    </html>
    
  3. Save the file and open it in a browser to see how the formatted text appears.

6. Summary

  • Text formatting allows you to style and emphasize content effectively.
  • Use semantic tags like <strong> and <em> to add both style and meaning.
  • Avoid excessive formatting to maintain readability and clarity.

This module equips you with the tools to format text in a visually appealing and meaningful way. In the next module, we’ll explore working with links to connect your web pages and resources seamlessly!