Author: Niraj Kumar Mahto

  • Embedded Content

    Embedding content into web pages allows you to include external resources like videos, documents, maps, and interactive media directly on your website. HTML provides various tags to embed this content, including <iframe><object><embed>, and <param>. Each tag serves different purposes and offers various functionalities.

    Embedding External Content with

    The <iframe> tag is used to embed external web content within a page. It’s commonly used for embedding videos (like YouTube), maps (like Google Maps), and other webpages.

    Basic Syntax:

    <iframe src="https://www.example.com" width="600" height="400"></iframe>

    Attributes:

    • src: URL of the content to be embedded.
    • width and height: Specifies the size of the embedded content.
    • title: Provides an accessible name for the iframe content.
    • allowfullscreen: Allows the embedded content to be viewed in fullscreen mode.
    • frameborder (Deprecated): Sets the border around the iframe. Use CSS for this purpose in modern HTML.
     
    Example: Embedding a YouTube Video:
    <iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ"
            title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

    The <iframe> is versatile and widely supported, making it a common choice for embedding various types of external content.

    The < object > Element

    The <object> element can embed different types of content, such as images, videos, PDFs, and even web pages. Unlike <iframe><object> is designed to handle different types of media and can act as a fallback mechanism if the content fails to load.

    Basic Syntax:

    <object data="document.pdf" type="application/pdf" width="600" height="400">
      <p>By clicking on download you can download the PDF. Download the PDF to view it: <a href="document.pdf">Download PDF</a>.</p>
    </object>

    Attributes:

    • data: Specifies the URL of the resource to be embedded.
    • type: Defines the MIME type of the content (e.g., application/pdf for PDFs).
    • width and height: Sets the size of the embedded content.
    • Fallback Content: You can provide fallback content inside the <object> tag if the browser does not support the embedded content.
     
    Example: Embedding an Image as Fallback:
    <object data="image.svg" type="image/svg+xml">
      <img decoding="async" src="fallback-image.jpg" alt="Fallback Image">
    </object>

    The <object> tag is useful when you need to embed content that might have a fallback option for older or less capable browsers.

    The < embed > Element

    The <embed> element is a self-closing tag used to embed external content like videos, PDFs, Flash content, and more. Unlike <object><embed> does not allow for fallback content.

    Basic Syntax:

    <embed src="video.mp4" width="600" height="400">

    Attributes:

    • src: URL of the resource to be embedded.
    • type: Defines the MIME type of the embedded content.
    • width and height: Specifies the size of the embedded content.
     
    Example: Embedding Audio:
    <embed src="audio.mp3" type="audio/mpeg" width="300" height="50">

    The <embed> tag is straightforward but less versatile than <object> since it doesn’t support fallback content. However, it’s quick for simple embedding tasks.

    The < param > Element

    The <param> tag is used within the <object> element to define parameters for the embedded content. It’s typically used for older technologies like Flash or media players that require specific configurations.

    Basic Syntax:

    <object data="movie.swf" type="application/x-shockwave-flash" width="600" height="400">
      <param name="autoplay" value="true">
      <param name="loop" value="false">
    </object>

    Attributes:

    • name: The name of the parameter to be set (e.g., autoplayloop).
    • value: The value for the specified parameter.

    The <param> tag is primarily associated with older media types (like Flash), which are becoming less common due to the rise of modern media embedding techniques (e.g., HTML5 <audio> and <video>).

    Summary

    Embedding external content in web pages can greatly enhance user interaction and functionality. HTML provides several tags for embedding:

    • <iframe> is versatile and commonly used for embedding web content like videos and maps.
    • <object> can handle multiple media types and allows for fallback content, making it suitable for a wider range of uses.
    • <embed> is used for directly embedding external media but lacks the ability to include fallback content.
    • <param> is used with <object> to configure settings for embedded content, though it is less commonly used with modern web technologies.

    Each of these elements has its strengths and is suited for different use cases, allowing web developers to embed a variety of media types into web pages effectively.

  • Web Graphics and Multimedia

    Web graphics and multimedia elements enhance user interaction and engagement on web pages. HTML5 introduces several features for creating and controlling graphics, animations, and multimedia, including the <canvas> element for 2D graphics, the <svg> element for vector graphics, CSS animations, and ways to add captions to multimedia content. This guide explores these features and how to implement them in web development.

    Using the < canvas> Element for Drawing Graphics

    The <canvas> element provides a blank drawing area in which you can render 2D graphics using JavaScript. This element does not have any drawing capabilities on its own but serves as a container for graphics drawn via a script.

    Basic Usage of <canvas>:
    <canvas id="myCanvas" width="300" height="300" style="border:1px solid #000;"></canvas>
    
    <script>
      var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');
    
      // Drawing a blue rectangle
      context.fillStyle = 'blue';
      context.fillRect(50, 50, 200, 150);
    </script>

    Explanation:

    • <canvas>: Defines the canvas area with specified width and height.
    • JavaScript: Uses the getContext('2d') method to get the drawing context, allowing you to use various drawing methods.
    • fillRect(x, y, width, height): Draws a rectangle on the canvas.
     
    More Drawing Methods:
    • Drawing Circles: Use arc() to create circles or arcs.
    • Drawing Text: Use fillText() or strokeText() to render text.
    • Drawing Lines: Use moveTo() and lineTo() in combination with stroke().
    <canvas id="Canvas01" width="300" height="150"></canvas>
    <script>
      var canvas = document.getElementById('Canvas01');
      var ctx = canvas.getContext('2d');
    
      // Draw a rectangle
      ctx.fillStyle = 'blue';
      ctx.fillRect(10, 10, 100, 50);
    
      // Draw a circle
      ctx.beginPath();
      ctx.arc(200, 75, 50, 0, 2 * Math.PI);
      ctx.fillStyle = 'green';
      ctx.fill();
    
      // Draw a line
      ctx.moveTo(0, 0);
      ctx.lineTo(300, 150);
      ctx.stroke();
    
      //drawing text
      ctx.font = '30px Arial';
      ctx.fillText('Hello, World!', 10, 50);
      ctx.strokeText('Stroke Text', 10, 100);
    </script>

    The <canvas> element is a powerful tool for creating dynamic, interactive graphics such as charts, games, and visualizations.

    Using the < svg > Element for Vector Graphics

    SVG (Scalable Vector Graphics) is an XML-based format for defining vector graphics. Unlike raster images (e.g., PNG, JPEG), SVG graphics are resolution-independent, making them perfect for responsive designs.

    Basic Usage of <svg>:
    <svg width="200" height="200">
      <circle cx="100" cy="100" r="80" stroke="green" stroke-width="4" fill="yellow" />
    </svg>

    Explanation:

    • <svg>: Container for SVG graphics, specifying its width and height.
    • <circle>: Draws a circle with the following attributes:
      • cxcy: The center coordinates of the circle.
      • r: The radius of the circle.
      • stroke: The color of the circle’s outline.
      • fill: The fill color of the circle.
     
    More SVG Elements:
    • <rect>: Draws rectangles.
    • <line>: Creates lines.
    • <polygon>: Defines a closed shape with multiple points.
    • <text>: Adds text within the SVG.
     
    Example: Creating a Simple SVG Graphic
    <svg width="300" height="200">
      <!-- Draw a rectangle -->
      <rect x="50" y="20" width="200" height="100" fill="blue" stroke="black" stroke-width="3" />
    
      <!-- Draw a line -->
      <line x1="50" y1="150" x2="250" y2="150" stroke="green" stroke-width="2" />
    
      <!-- Draw text -->
      <text x="150" y="180" font-size="20" text-anchor="middle">Hello, SVG!</text>
    </svg>

    SVG is excellent for creating complex graphics, icons, logos, charts, and diagrams that need to scale across different screen sizes.

    Animations with SVG and CSS

    You can animate SVG elements using either CSS animations or SVG’s built-in animation elements like <animate>.

    Using CSS to Animate SVG:
    <svg width="200" height="200">
      <circle cx="100" cy="100" r="50" fill="red" class="pulse" />
    </svg>
    
    <style>
      .pulse {
        animation: pulse-animation 2s infinite;
      }
    
      @keyframes pulse-animation {
        0% {
          r: 50;
          fill: red;
        }
        50% {
          r: 70;
          fill: orange;
        }
        100% {
          r: 50;
          fill: red;
        }
      }
    </style>
    Using SVG Animation (<animate>):
    <svg width="200" height="200">
      <circle cx="100" cy="100" r="50" fill="blue">
        <animate attributeName="r" from="50" to="80" dur="2s" repeatCount="indefinite" />
      </circle>
    </svg>

    Explanation:

    • <animate>: Specifies the animation properties directly within the SVG.
    • attributeName: The SVG attribute you want to animate (e.g., r for radius).
    • fromto: Defines the starting and ending values.
    • dur: Specifies the duration of the animation.
    • repeatCount: Determines how many times the animation should repeat (indefinite for infinite).

    Adding Captions to Multimedia Elements

    Adding captions to multimedia elements like images, audio, and video is essential for accessibility and context.

    Using <figcaption> for Images:
    <figure>
      <img decoding="async" src="mountain.jpg" alt="A beautiful mountain landscape">
      <figcaption>A stunning mountain view during sunset.</figcaption>
    </figure>
    Captions for Video and Audio:
    • For Video: Use the <track> element within the <video> tag to add subtitles or captions.
    <video width="600" controls>
      <source src="sample-video.mp4" type="video/mp4">
      <track src="captions.vtt" kind="subtitles" srclang="en" label="English">
      Your browser does not support the video element.
    </video>
    • <track> Element Attributes:
      • src: Path to the caption file (e.g., WebVTT format).
      • kind: Specifies the type of text track (e.g., subtitles).
      • srclang: Language of the track content.
      • label: Title of the track, displayed to the user.

    Summary

    HTML5 provides robust tools for adding graphics and multimedia to web pages. The <canvas> element allows for dynamic, scriptable rendering of 2D graphics, ideal for games, charts, and animations. SVG offers a resolution-independent way to define vector graphics with built-in support for animations. Additionally, CSS and SVG animations enable dynamic visual effects without the need for external plugins. For multimedia content like images, audio, and video, HTML5 offers simple methods for adding captions and subtitles, enhancing accessibility and providing better context. By leveraging these features, you can create engaging, interactive web experiences.

  • HTML5 Features

    HTML5 brought a lot of cool features that make building websites easier and more powerful. Whether it’s adding videos, improving forms, or making your page more accessible, HTML5 has you covered. Let’s walk through some of these features in a simple way.

    New Elements in HTML5

    HTML5 introduced some new elements that help structure your webpage better. These new tags tell both browsers and search engines what each part of your page is about.

    Key Semantic Elements: Making Your Code Clearer

    • <main>: This is where the main content of your page goes. It should be unique to the page and not include things like headers, footers, or sidebars.
    <main>
      <h1>Welcome to My Website</h1>
      <p>This is the main content you'll find on this page.</p>
    </main>
    • <section>: Use this to group related content together, usually with a heading. Think of it like chapters in a book.
    <section>
      <h2>About Us</h2>
      <p>Learn more about our company here.</p>
    </section>
    • <article>: Perfect for stuff that can stand on its own, like a blog post, news article, or even a forum post.
    <article>
      <h2>Latest News</h2>
      <p>Here's what's happening today...</p>
    </article>
    • <aside>: This is for content related to the main content, but not essential. It’s great for sidebars, ads, or links to related articles.
    <aside>
      <h3>Related Links</h3>
      <ul>
        <li><a href="#">Web Design Basics</a></li>
        <li><a href="#">Getting Started with CSS</a></li>
      </ul>
    </aside>
    • <header> and <footer>: These are for the top and bottom of your page or sections. You can include things like logos, navigation links, or copyright info.
    <header>
      <h1>My Awesome Site</h1>
      <nav>
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
        </ul>
      </nav>
    </header>
    
    <footer>
      <p>&copy; 2024 My Company</p>
    </footer>
    • <figure> and <figcaption>: Use these when you have an image, diagram, or illustration, and want to add a caption.
    <figure>
      <img decoding="async" src="landscape.jpg" alt="Mountain landscape">
      <figcaption>A stunning view of the mountains.</figcaption>
    </figure>

    Multimedia Elements

    HTML5 made it super easy to add audio and video to your website without needing extra plugins.

    • <audio>: Embed audio files like music or podcasts with just one tag. You can even add controls like play, pause, and volume.
    <audio controls>
      <source src="song.mp3" type="audio/mpeg">
      Your browser doesn't support audio playback.
    </audio>
    • <video>: Want to add a video? Use the <video> tag. You can set the size, add controls, and even let viewers go full-screen.
    <video width="640" height="360" controls>
      <source src="movie.mp4" type="video/mp4">
      Sorry, your browser doesn't support video playback.
    </video>

    Graphics Elements

    With HTML5, you can draw shapes, create animations, and even build simple games directly in your browser.

    • <canvas>: This is like a blank canvas for painting with JavaScript. It’s great for making graphs, animations, and other dynamic visuals.
    <canvas id="myCanvas" width="200" height="200"></canvas>
    <script>
      var canvas = document.getElementById('myCanvas');
      var context = canvas.getContext('2d');
      context.fillStyle = 'blue';
      context.fillRect(50, 50, 100, 100);
    </script>
    • SVG (Scalable Vector Graphics): SVG is perfect for drawing shapes like circles, rectangles, and paths. It’s scalable, so it looks good on any screen size.
    <svg width="100" height="100">
      <circle cx="50" cy="50" r="40" stroke="black" stroke-width="2" fill="red" />
    </svg>

    Form Enhancements

    HTML5 added new input types and features that make forms easier to use and more interactive.

    • New Input Types: HTML5 has new input types like emailurlnumberdaterange, and color to make sure users input the right kind of data.
    <input type="email" name="user_email" placeholder="Enter your email">
    • <datalist>: This lets you give users a list of suggestions when they start typing.
    <label for="browsers">Choose a browser:</label>
    <input list="browsers" id="browser" name="browser">
    <datalist id="browsers">
      <option value="Chrome">
      <option value="Firefox">
      <option value="Safari">
      <option value="Edge">
    </datalist>

    HTML5 APIs

    • HTML5 came with new tools (APIs) that add more advanced features to your site.
      • Geolocation: Find out the user’s location. This is useful for things like maps and location-based services.
    <button onclick="getLocation()">Get My Location</button>
    <p id="location"></p>
    
    <script>
      function getLocation() {
        if (navigator.geolocation) {
          navigator.geolocation.getCurrentPosition(function(position) {
            document.getElementById('location').innerHTML =
              "Latitude: " + position.coords.latitude +
              "<br>Longitude: " + position.coords.longitude;
          });
        } else {
          document.getElementById('location').innerHTML = "Geolocation is not supported.";
        }
      }
    </script>
    • Drag and Drop: Let users drag items around on your page.
    <div id="drag" draggable="true" ondragstart="drag(event)">Drag me!</div>
    
    <script>
      function drag(event) {
        event.dataTransfer.setData("text", event.target.id);
      }
    </script>
    • Drag and Drop: Let users drag items around on your page.
    // Save data
    localStorage.setItem('username', 'JohnDoe');
    
    // Retrieve data
    var user = localStorage.getItem('username');

    Wrapping Up

    HTML5 is packed with features that make building websites more fun and interactive. From new tags that give structure to your content, to audio, video, and graphics that add some flair, HTML5 is all about giving you more power and flexibility. Plus, with new form inputs and APIs, it’s easier than ever to create engaging, user-friendly websites.

  • Semantic HTML

    Semantic HTML refers to using HTML elements that clearly define the meaning of the content they enclose. These elements help both browsers and search engines understand the structure of your web pages and improve accessibility for users, especially those using screen readers or other assistive technologies.

    Page structure in HTML5

    Semantic Elements in HTML

    Semantic elements give structure to your webpage in a way that’s easy to understand for both humans and machines. They describe what their content represents, which helps make your code clearer and more organized.

    Key Semantic Elements:

    • <header>: The top section of a webpage or a section, usually containing the logo, navigation menu, or a page title.
    <header>
      <h1>My Website</h1>
      <nav>
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">About</a></li>
          <li><a href="#">Contact</a></li>
        </ul>
      </nav>
    </header>
    • <nav>: Defines a block of navigation links, such as a website menu or table of contents.
    <nav>
      <ul>
        <li><a href="#section1">Section 1</a></li>
        <li><a href="#section2">Section 2</a></li>
      </ul>
    </nav>
    • <main>: Represents the main content area of a webpage. This is the core part of the page and should exclude things like navigation links or sidebars.
    <main>
      <article>
        <h2>Main Article Title</h2>
        <p>This is the primary content of the page.</p>
      </article>
    </main>
    • <section>: Groups related content, typically with its own heading. This is great for organizing your webpage into thematic blocks.
    <section>
      <h2>About Us</h2>
      <p>Information about our company.</p>
    </section>
    • <article>: Represents a stand-alone piece of content, such as a blog post, news story, or forum post.
    <article>
      <h2>Blog Post Title</h2>
      <p>This is an independent piece of content.</p>
    </article>
    • <aside>: Contains related content, such as sidebars, links, or advertisements, that complements the main content but isn’t central to it.
    <aside>
      <h3>Related Articles</h3>
      <ul>
        <li><a href="#">Article 1</a></li>
        <li><a href="#">Article 2</a></li>
      </ul>
    </aside>
    • <footer>: The footer typically contains links, copyright information, or contact details. It appears at the bottom of a webpage or section.
    <footer>
      <p>&copy; 2024 Your Company</p>
    </footer>
    • <figure>: Wraps content like images, diagrams, or charts, often accompanied by a caption.
    <figure>
      <img decoding="async" src="image.jpg" alt="A description of the image">
      <figcaption>Caption for the image</figcaption>
    </figure>
    • <figcaption>: Provides a caption for content in a <figure> element, adding a description or extra context.

    Benefits of Semantic HTML

    Using semantic HTML elements provides a wide range of advantages:

    1. Improved Accessibility

    Semantic elements make it easier for screen readers and assistive technologies to understand and navigate your content:

    • A screen reader can easily identify the main sections of your webpage, like the <header> or <footer>.
    • The <nav> element helps users jump straight to navigation links, skipping over less important content.
     
    2. Better SEO (Search Engine Optimization)

    Search engines, like Google, use semantic tags to better understand the structure of a webpage. This can help improve your site’s ranking by:

    • Recognizing the content within <main><article>, and <section> as the most important.
    • Ensuring that headings within these sections get more weight, improving relevance for keywords.
     
    3. Code Readability and Maintainability

    Using semantic elements makes your code easier to read and understand:

    • Other developers (or even your future self!) can quickly figure out the structure of your page.
    • It reduces ambiguity and makes it clear what each section of your webpage is meant for.
     
    4. Future-Proofing

    HTML evolves, but semantic elements are here to stay. By using them, you ensure that your code will be more compatible with future standards.

    Using Semantic Elements for Accessibility and SEO

    Accessibility Benefits
    • Screen Readers: Semantic elements help screen readers navigate through the page more efficiently. For example:
      • The <header> and <footer> elements are recognized as distinct sections, giving users clear cues about the content.
      • The <nav> element allows users to skip directly to the navigation, saving them from having to scroll through other content.
    • Landmarks: Semantic elements like <main><aside><nav>, and <footer> serve as landmarks, helping users of assistive technologies quickly jump to the relevant parts of the webpage.
    • ARIA Roles: Combining semantic elements with ARIA roles (Accessible Rich Internet Applications) can further enhance accessibility by providing additional context to non-semantic HTML elements.
    SEO Benefits

    Semantic HTML helps search engines prioritize content and improve rankings by:

    • Understanding Key Content: Search engines look at content inside <article><section>, and <main> to determine the key topics and themes of the page.
    • Improving Content Structure: Using semantic elements ensures a clear content hierarchy, making it easier for search engines to crawl and index your webpage properly.

    Summary

    Semantic HTML gives structure and meaning to your webpage, benefiting both accessibility and search engine optimization. Key elements like <header><main><section>, and <article> provide clear definitions of different sections of your content, making it easier for browsers, screen readers, and search engines to understand your page. By embracing semantic HTML, you’re not only future-proofing your code but also enhancing user experience for all your visitors.

  • Forms and Input

    Forms are essential for collecting user input on web pages. HTML provides a range of form elements and input types to gather various kinds of information. This guide covers the fundamental form elements, input types, form attributes, validation, and some advanced form elements introduced in HTML5.

    Input Types in HTML

    Form Elements

    HTML forms consist of a collection of elements used to gather information from the user.

    Basic Form Structure (<form>)

    The <form> tag is the container for all input elements. The action and method attributes define where and how to send the form data.

    <form action="/submit-form" method="post">
      <label for="username">Username:</label>
      <input type="text" id="username" name="username">
    
      <label for="email">Email:</label>
      <input type="email" id="email" name="email">
    
      <button type="submit">Submit</button>
    </form>
    Common Form Elements
    • <input>: The most versatile form element, used for various input types like text, email, password, number, etc.
    <input type="text" name="username" placeholder="Enter your username">
    • <textarea>: For multi-line text input.
    <textarea name="message" rows="4" cols="50" placeholder="Enter your message here"></textarea>
    • <button>: Defines a clickable button, often used to submit the form.
    <button type="submit">Submit</button>
    • <select>  and  <option>: Used to create a drop-down list.
    <label for="cars">Choose a car:</label>
    <select id="cars" name="cars">
      <option value="volvo">Volvo</option>
      <option value="saab">Saab</option>
      <option value="mercedes">Mercedes</option>
      <option value="audi">Audi</option>
    </select>
    • <label>: Associates a text label with a form element. The for attribute of the <label> corresponds to the id of the form element.
    <label for="email">Email:</label>
    <input type="email" id="email" name="email">
    • <fieldset> and <legend>: Used to group related form elements together. The <legend> provides a caption for the group.
    <fieldset>
      <legend>Personal Information</legend>
      <label for="name">Name:</label>
      <input type="text" id="name" name="name">
    
      <label for="age">Age:</label>
      <input type="number" id="age" name="age">
    </fieldset>

    Input Types

    The <input> element has many types, each designed to handle a different kind of data. Here are some commonly used input types:

    • text: For single-line text input.
    <input type="text" name="name" placeholder="Enter your name">
    • password: Hides the input with dots or asterisks.
    <input type="password" name="password" placeholder="Enter your password">
    • email: Validates that the input is in an email format.
    <input type="email" name="email" placeholder="Enter your email">
    • number: Restricts input to numerical values.
    <input type="number" name="age" min="1" max="100" placeholder="Enter your age">
    • date: Provides a date picker.
    <input type="date" name="birthday">

    Form Attributes

    The <form> element has several important attributes:

    • action: Specifies the URL where the form data is sent when it is submitted.
    <form action="/submit-form" method="post">
    • method: Defines how the form data is sent. Common values are:
      • get: Appends form data to the URL, used for non-sensitive data.
      • post: Sends form data as an HTTP POST request, suitable for sensitive or large amounts of data.
    • enctype: Used with method="post" to specify how form data should be encoded. Common values:
      • application/x-www-form-urlencoded (default): Encodes form data in the URL.
      • multipart/form-data: Used for forms with file uploads.
    <form action="/upload" method="post" enctype="multipart/form-data">
    • target: Specifies where to display the response. Common values:
      • _self (default): Opens in the same window.
      • _blank: Opens in a new window or tab.
    <form action="/submit" method="post" target="_blank">

    Validation and Error Messages

    HTML5 provides built-in form validation without JavaScript. You can use various attributes to enforce rules on the input fields:

    • required: Specifies that the input field must be filled out.
    <input type="text" name="username" required>
    • minmax: Sets the minimum and maximum values for numeric inputs.
    <input type="number" name="age" min="1" max="100">
    • pattern: Defines a regular expression that the input’s value must match.
    <input type="text" name="zipcode" pattern="[0-9]{5}" placeholder="Enter 5-digit ZIP code">
    • maxlengthminlength: Sets the maximum and minimum number of characters allowed.
    <input type="text" name="username" minlength="4" maxlength="12">
    • Error Messages: When the user enters invalid input, the browser displays a built-in error message. You can customize this using the title attribute or JavaScript for advanced control.

    Advanced Form Elements

    <datalist>

    The <datalist> element provides a list of pre-defined options for an <input> element, creating an auto-complete effect.

    <label for="browsers">Choose a browser:</label>
    <input list="browsers" id="browser" name="browser">
    <datalist id="browsers">
      <option value="Chrome">
      <option value="Firefox">
      <option value="Safari">
      <option value="Edge">
    </datalist>
    <output>

    The <output> element displays the result of a calculation or an action.

    <form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
      <input type="number" id="a" value="0"> +
      <input type="number" id="b" value="0"> =
      <output name="result" for="a b">0</output>
    </form>
    <keygen> (Deprecated)

    The <keygen> element was used for generating a key-pair for forms that use certificates for authentication. However, it has been deprecated and is not recommended for use in modern web development.

    HTML5 Input Types and Attributes

    HTML5 introduced several new input types and attributes to enhance form functionality:

    • search: Similar to text but optimized for search queries.
    <input type="search" name="query" placeholder="Search...">
    • range: Provides a slider control for numeric input.
    <input type="range" name="volume" min="0" max="100">
    • color: Opens a color picker.
    <input type="color" name="favcolor">
    • tel: For telephone numbers. Offers some validation and custom keyboard on mobile devices.
    <input type="tel" name="phone" placeholder="123-456-7890">

    Summary

    HTML forms are an essential tool for gathering user input. By using elements like <input><textarea><select>, and form attributes such as action and method, you can create interactive and user-friendly forms. HTML5 introduced new input types (e.g., emailnumberrange) and attributes (e.g., requiredpattern) to enhance form validation and functionality. Additionally, advanced elements like <datalist> and <output> provide more dynamic user interactions, while built-in validation simplifies error checking without JavaScript. Understanding these elements and how to use them effectively is key to building robust web forms.

  • Tables

    HTML tables let you organize data in neat rows and columns, kind of like a spreadsheet. They’re great for displaying structured information, and you can style them to look pretty awesome too. In this guide, we’ll go over the basics of HTML tables, important attributes, and how to make them look better with some CSS.

    HTML Table

    Basic Table Structure ( < table >, < tr >, < th >, < td >)

    To create a table in HTML, you use a few key elements:

    • <table>: This holds the entire table.
    • <tr>: Each row in the table.
    • <th>: Header cells (usually bold and centered).
    • <td>: Regular data cells.

    Basic Example:

    <table>
      <tr>
        <th>First Name</th>
        <th>Last Name</th>
        <th>Age</th>
      </tr>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>28</td>
      </tr>
      <tr>
        <td>Jane</td>
        <td>Smith</td>
        <td>34</td>
      </tr>
    </table>

    This will show up like this:

    First NameLast NameAge
    JohnDoe28
    JaneSmith34

    Table Attributes (border, cellpadding, cellspacing)

    There are a few attributes you can use to adjust the spacing and look of your table.

    Border Attribute

    The border attribute adds a border around your table. It’s better to use CSS for this, but for quick styling, it works.

    <table border="1">
      <tr>
        <th>Name</th>
        <th>Age</th>
      </tr>
      <tr>
        <td>John</td>
        <td>28</td>
      </tr>
    </table>

    This creates a table with borders around the cells.

    Cellpadding and Cellspacing
    • cellpadding: Adds space inside each cell, between the content and the border.
    • cellspacing: Adds space between the cells themselves.
    <table border="1" cellpadding="10" cellspacing="5">
      <tr>
        <th>Name</th>
        <th>Age</th>
      </tr>
      <tr>
        <td>John</td>
        <td>28</td>
      </tr>
    </table>

    Here, cellpadding="10" adds space inside the cells, and cellspacing="5" adds space between the cells.

    Table Headers and Footers

    For bigger tables, it helps to organize your content into sections using <thead><tbody>, and <tfoot>.

    Basic Example:

    <table border="1">
      <thead>
        <tr>
          <th>Name</th>
          <th>Age</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>John</td>
          <td>28</td>
        </tr>
        <tr>
          <td>Jane</td>
          <td>34</td>
        </tr>
      </tbody>
      <tfoot>
        <tr>
          <td colspan="2">End of Data</td>
        </tr>
      </tfoot>
    </table>

    Here’s how it works:

    • <thead>: Holds the table headers.
    • <tbody>: Holds the actual data rows.
    • <tfoot>: Holds any footer info, like summaries or notes.

    Colspan and Rowspan Attributes

    Need to merge cells? Use colspan to make a cell span across multiple columns, and rowspan to span across rows.

    Colspan Example:
    <table border="1">
      <tr>
        <th colspan="2">Name</th>
        <th>Age</th>
      </tr>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>28</td>
      </tr>
    </table>

    This merges two header cells into one:

    Name Age
    JohnDoe28
    Rowspan Example:
    <table border="1">
      <tr>
        <th>Name</th>
        <th rowspan="2">Age</th>
      </tr>
      <tr>
        <td>John</td>
      </tr>
      <tr>
        <td>Jane</td>
        <td>34</td>
      </tr>
    </table>

    This merges the “Age” cell across two rows:

    NameAge
    John28
    Jane34

    Styling Tables with CSS

    You can style tables using CSS to make them look cleaner and more polished.

    Basic Table Styling:
    <table class="styled-table">
      <thead>
        <tr>
          <th>Name</th>
          <th>Age</th>
        </tr>
      </thead>
      <tbody>
        <tr>
          <td>John</td>
          <td>28</td>
        </tr>
        <tr>
          <td>Jane</td>
          <td>34</td>
        </tr>
      </tbody>
    </table>
    
    <style>
      .styled-table {
        border-collapse: collapse;
        width: 100%;
      }
      .styled-table th, .styled-table td {
        border: 1px solid #ddd;
        padding: 8px;
      }
      .styled-table th {
        background-color: #f2f2f2;
        text-align: left;
      }
      .styled-table tr:hover {
        background-color: #f1f1f1;
      }
    </style>
    • border-collapse: Merges the borders into one.
    • Padding: Adds space inside the cells.
    • Hover effect: Highlights a row when you hover over it.

     

    Zebra Striped Table:

    Zebra striping alternates the row colors to make the table easier to read.

    <style>
      .styled-table tr:nth-child(even) {
        background-color: #f9f9f9;
      }
      .styled-table tr:nth-child(odd) {
        background-color: #fff;
      }
    </style>

    This creates alternating row colors for better readability.

    Summary

    Tables in HTML are super handy for organizing data into rows and columns. The basic structure includes tags like <table><tr><th>, and <td>. You can use attributes like bordercellpadding, and cellspacing to adjust the table’s spacing and appearance. More advanced tags like <thead><tbody>, and <tfoot> help with larger tables, and colspan and rowspan allow you to merge cells. Finally, with CSS, you can make your tables look polished with features like hover effects and zebra stripes.

  • Lists

    Lists are a great way to organize information and make it easy to follow. HTML gives you different types of lists, like ordered lists for numbered items, unordered lists with bullets, and description lists for terms and definitions. Let’s dive into how to use them, nest them, and style them with CSS to create more structured content.

    ordered and unordered list

    Ordered Lists ( < ol >)

    An ordered list is used when the order matters, like steps in a process or a ranked list. The items are usually numbered by default.

    Basic Example:

    <ol>
      <li>First item</li>
      <li>Second item</li>
      <li>Third item</li>
    </ol>

    This will show up as:

    1. First item
    2. Second item
    3. Third item
     
    Customizing Ordered Lists

    You can change the numbering style using the type attribute:

    • type="1": Numbers (1, 2, 3…)
    • type="A": Uppercase letters (A, B, C…)
    • type="a": Lowercase letters (a, b, c…)
    • type="I": Roman numerals (I, II, III…)
    • type="i": Lowercase Roman numerals (i, ii, iii…)

    Example:

    <ol type="A">
      <li>First item</li>
      <li>Second item</li>
      <li>Third item</li>
    </ol>

    This will render as:

    A. First item
    B. Second item
    C. Third item

    Unordered Lists (< ul > )

    An unordered list is great for items that don’t need to be in any particular order, like shopping lists or random ideas. The items are usually marked with bullet points.

    Basic Example:

    <ul>
      <li>Apple</li>
      <li>Banana</li>
      <li>Cherry</li>
    </ul>

    This will show up as:

    • Apple
    • Banana
    • Cherry
     
    Changing Bullet Styles

    You can change the bullet style using the type attribute or with CSS:

    • type="disc": Solid bullet (●)
    • type="circle": Hollow circle (○)
    • type="square": Solid square (■)

    Example:

    <ul type="circle">
      <li>Apple</li>
      <li>Banana</li>
      <li>Cherry</li>
    </ul>

    This will render as:

    ○ Apple
    ○ Banana
    ○ Cherry

    Description Lists ( < dl >, < dt >, < dd >,)

    description list is for pairing terms with their descriptions, like a glossary or a list of definitions.

    Basic Example:

    <dl>
      <dt>HTML</dt>
      <dd>A markup language for creating web pages.</dd>
    
      <dt>CSS</dt>
      <dd>A style sheet language used for describing the look of a webpage.</dd>
    </dl>

    This will display as:

    HTML
    A markup language for creating web pages.

    CSS
    A style sheet language used for describing the look of a webpage.

    Nesting Lists

    You can nest lists inside one another to create a hierarchy. For example, you might want to list categories, and then list items within those categories.

    Example:
    <ol>
      <li>Fruits
        <ul>
          <li>Apple</li>
          <li>Banana</li>
          <li>Cherry</li>
        </ul>
      </li>
      <li>Vegetables
        <ul>
          <li>Carrot</li>
          <li>Broccoli</li>
          <li>Spinach</li>
        </ul>
      </li>
    </ol>

    This will display as:

    1. Fruits
      • Apple
      • Banana
      • Cherry
    2. Vegetables
      • Carrot
      • Broccoli
      • Spinach

    Styling Lists

    You can use CSS to change how lists look, from adjusting bullet types to removing them altogether.

    Styling Unordered Lists with CSS

    To change bullet types, you can use list-style-type in CSS.

    Example:

    <ul class="custom-list">
      <li>Apple</li>
      <li>Banana</li>
      <li>Cherry</li>
    </ul>
    
    <style>
      .custom-list {
        list-style-type: square;
      }
    </style>

    This will show square bullets:

    ■ Apple
    ■ Banana
    ■ Cherry

    Hiding List Markers

    If you want to remove bullets or numbers, you can use list-style-type: none.

    Example:

    <ul class="no-bullets">
      <li>Apple</li>
      <li>Banana</li>
      <li>Cherry</li>
    </ul>
    
    <style>
      .no-bullets {
        list-style-type: none;
        padding: 0;
      }
    </style>

    This will display the list without any bullets:

          Apple

         Banana

         Cherry

    Adjusting List Spacing

    To add space between items, you can use margin or padding with CSS.

    Example:

    <ul class="spaced-list">
      <li>Apple</li>
      <li>Banana</li>
      <li>Cherry</li>
    </ul>
    
    <style>
      .spaced-list li {
        margin-bottom: 10px;
      }
    </style>

    This will add some space between the items, making the list more readable.

    Summary

    HTML lists are a handy way to present content in an organized way. Ordered lists (<ol>) work well for items that need to be in sequence, while unordered lists (<ul>) are perfect for things like bullet points. Description lists (<dl>) are great for pairing terms with definitions. You can nest lists for more complex layouts, and CSS lets you tweak the look and feel of your lists. Mastering these list types will help you better organize content on your web pages.

  • HTML Multimedia Elements

    Multimedia like images, videos, and audio can make your website more engaging and visually interesting. HTML has built-in tags that make adding this content super easy. In this guide, we’ll look at how to add images, videos, audio, embed YouTube videos, and use the <picture> element for responsive images.

    Images ( < img >)

    The <img> tag lets you show images on your website. It’s a self-closing tag that needs a few important attributes: src (where your image file is located) and alt (a description for accessibility).

    Basic Example:

    <img decoding="async" src="image.jpg" alt="A description of the image">

    Key Attributes:

    • src: The path to the image file.
    • alt: Text that describes the image (for when it doesn’t load or for screen readers).
    • width and height: Optional, to define the image size in pixels.

    Example:

    <img fetchpriority="high" decoding="async" src="nature.jpg" alt="Beautiful nature scenery" width="500" height="300">

    Videos (< video >)

    You can add videos to your site using the <video> tag. Unlike embedding a YouTube video, this lets you play video files directly from your server.

    Basic Example:

    <video controls>
      <source src="video.mp4" type="video/mp4">
      Your browser does not support the video tag.
    </video>

    Key Attributes:

    • controls: Shows playback controls (play, pause, volume).
    • autoplay: Automatically starts the video when the page loads.
    • loop: Replays the video continuously.
    • muted: Mutes the audio.

    Example:

    <video width="600" controls>
      <source src="sample.mp4" type="video/mp4">
      Your browser does not support the video tag.
    </video>

    Audio (< audio >)

    To add audio to your site, use the <audio> tag. This is great for music, podcasts, or any sound content.

    Basic Example:

    <audio controls>
      <source src="audio.mp3" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>

    Key Attributes:

    • controls: Shows play/pause and volume controls.
    • autoplay: Starts playing the audio as soon as the page loads.
    • loop: Replays the audio continuously.

    Example:

    <audio controls>
      <source src="song.mp3" type="audio/mpeg">
      Your browser does not support the audio element.
    </audio>

    Embedding YouTube Videos

    Instead of hosting videos on your own server, it’s common to embed YouTube videos. This saves space and is super simple using an <iframe>.

    Basic Example:

    <iframe width="540" height="300" src="https://www.youtube.com/embed/videoid" frameborder="2" allowfullscreen></iframe>

    <iframe width="560" height="315" src="https://www.youtube.com/embed/VIDEO_ID"
            frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
            allowfullscreen></iframe>
    • src: The YouTube link, starting with https://www.youtube.com/embed/ and followed by the video ID.
    • allowfullscreen: Allows the video to be played in fullscreen mode.

    Example:

    <iframe width="560" height="315" src="https://www.youtube.com/embed/dQw4w9WgXcQ"
            frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

    Using the Element for Responsive Images

    The <picture> element is handy for showing different versions of an image based on screen size. This is great for responsive design so users see the best quality image for their device.

    Basic Example:

    <picture>
      <source media="(min-width: 800px)" srcset="large.jpg">
      <source media="(min-width: 500px)" srcset="medium.jpg">
      <img decoding="async" src="small.jpg" alt="Responsive image">
    </picture>
    • <source>: Defines different images depending on screen width.
    • media: Sets the conditions for when each image is shown (based on screen size).
    • <img>: The fallback image if none of the conditions are met.

    How It Works:

    • 800px or wider: Displays large.jpg.
    • 500px to 800px: Displays medium.jpg.
    • Less than 500px: Displays small.jpg.

    Example for High-Resolution Screens (like Retina):

    <picture>
      <source srcset="image-2x.jpg 2x, image-1x.jpg 1x">
      <img decoding="async" src="image-1x.jpg" alt="High-resolution image">
    </picture>

    This will show image-2x.jpg for high-res displays and image-1x.jpg for regular screens.

    Summary

    HTML makes it easy to add multimedia elements like images, videos, and audio to your website. The <img> tag is essential for displaying images, while <video> and <audio> allow you to add media files with built-in controls. Embedding YouTube videos using <iframe> is a simple way to share videos, and the <picture> element helps with responsive images, ensuring the right image loads on the right screen. Adding these elements enhances the user experience and keeps your site engaging.

  • HTML Links and Navigation

    Creating effective navigation is crucial for user experience on a website. HTML provides various tools for linking pages and building navigation bars and dropdown menus. In this guide, we’ll explore hyperlinks, bookmarks, navigation bars, and dropdown menus, which help users move through web pages and interact with content easily.

    Hyperlinks ( < a >)

    The anchor (<a>) tag is used to create hyperlinks in HTML. Hyperlinks allow users to navigate from one page to another, whether it’s within the same website or to an external website.

    Basic Structure of a Hyperlink:

    <a href="URL">Clickable Text</a>
    • href Attribute: The href attribute specifies the URL of the page the link should point to.
    • Text: The text inside the <a> tag is the clickable part of the hyperlink.

    Example: Linking to an External Website:

    <a href="https://www.example.com">Visit Example</a>

    Example: Linking to Another Page on Your Website:

    <a href="about.html">About Us</a>
    Opening Links in a New Tab

    You can make the link open in a new tab by adding the target="_blank" attribute to the <a> tag.

    <a href="https://www.example.com" target="_blank">Open Example in a New Tab</a>
    Adding Titles to Links

    You can add a title to provide additional information about the link when users hover over it.

    <a href="https://www.example.com" title="Go to Example website">Visit Example</a>

    Creating Bookmarks

    Bookmarks, also known as fragment identifiers, allow users to jump to a specific section within the same page. You can use anchor links to create these bookmarks.

    Step 1: Create a Bookmark (ID)

    Assign an id attribute to the section of the page where you want the link to jump.

    <h2 id="section1">Section 1</h2>
    <p>This is the content of section 1.</p>

    Step 2: Create a Link to the Bookmark

    Use an anchor link with a hash symbol (#) followed by the id of the section to create the bookmark link.

    <a href="#section1">Go to Section 1</a>

    Full Example:

    <h2 id="section1">Section 1</h2>
    <p>This is the content of section 1.</p>
    
    <h2 id="section2">Section 2</h2>
    <p>This is the content of section 2.</p>
    
    <a href="#section1">Go to Section 1</a>
    <a href="#section2">Go to Section 2</a>

    When a user clicks on the link, they will be navigated to the corresponding section of the page.

    Navigation Bars

    navigation bar (nav bar) is a section of a webpage that contains links to other pages or sections. Navigation bars help users move through a website.

    Creating a Basic Navigation Bar

    You can create a basic nav bar by combining unordered lists (<ul> and <li>) and anchor (<a>) tags. Styling with CSS can further enhance the appearance and functionality.

    <nav>
      <ul>
        <li><a href="index.html">Home</a></li>
        <li><a href="about.html">About</a></li>
        <li><a href="services.html">Services</a></li>
        <li><a href="contact.html">Contact</a></li>
      </ul>
    </nav>

    CSS Example to Style the Navigation Bar:

    <style>
      nav ul {
        list-style-type: none;
        padding: 0;
        margin: 0;
        display: flex;
        background-color: #333;
      }
    
      nav ul li {
        margin-right: 20px;
      }
    
      nav ul li a {
        color: white;
        text-decoration: none;
        padding: 10px;
        display: block;
      }
    
      nav ul li a:hover {
        background-color: #111;
      }
    </style>

    In this example, we:

    • Set the navigation bar links to appear inline (using display: flex).
    • Removed the list styling (bullets and padding).
    • Added hover effects for better user interaction.
     
    Fixed Navigation Bar

    You can make the navigation bar “sticky” so it stays at the top of the page even when scrolling.

    CSS for a Fixed Navigation Bar:

    nav {
      position: fixed;
      top: 0;
      width: 100%;
      background-color: #333;
      z-index: 1000; /* Ensures the nav stays on top */
    }

    This ensures the navigation bar remains visible at the top of the page as the user scrolls.

    Dropdown Menus

    Dropdown menus provide additional links or options that appear when the user hovers or clicks on a button or link.

    Creating a Simple Dropdown Menu

    You can create a dropdown menu by using the <ul> and <li> elements for the navigation and a nested <ul> for the dropdown.

    <nav>
      <ul>
        <li><a href="index.html">Home</a></li>
        <li>
          <a href="services.html">Services</a>
          <ul>
            <li><a href="web-development.html">Web Development</a></li>
            <li><a href="seo.html">SEO</a></li>
            <li><a href="marketing.html">Marketing</a></li>
          </ul>
        </li>
        <li><a href="contact.html">Contact</a></li>
      </ul>
    </nav>

    CSS to Style the Dropdown:

    nav ul {
      list-style-type: none;
      padding: 0;
      margin: 0;
      display: flex;
    }
    
    nav ul li {
      position: relative;
    }
    
    nav ul li ul {
      display: none;
      position: absolute;
      top: 100%;
      left: 0;
      background-color: #333;
      padding: 0;
      margin: 0;
    }
    
    nav ul li:hover ul {
      display: block;
    }
    
    nav ul li ul li {
      display: block;
    }
    
    nav ul li a {
      color: white;
      text-decoration: none;
      padding: 10px;
      display: block;
    }
    
    nav ul li ul li a:hover {
      background-color: #111;
    }

    Explanation:

    • Dropdown Structure: We use an unordered list (<ul>) nested inside another list item (<li>).
    • display: none: Hides the dropdown by default.
    • :hover Selector: Shows the dropdown menu when the user hovers over the parent list item.
    Adding Click-to-Open Dropdown Menus

    For dropdown menus that open on click rather than hover, you can use JavaScript:

    <nav>
      <ul>
        <li><a href="index.html">Home</a></li>
        <li>
          <a href="#" onclick="toggleDropdown()">Services</a>
          <ul id="dropdownMenu">
            <li><a href="web-development.html">Web Development</a></li>
            <li><a href="seo.html">SEO</a></li>
            <li><a href="marketing.html">Marketing</a></li>
          </ul>
        </li>
        <li><a href="contact.html">Contact</a></li>
      </ul>
    </nav>
    
    <script>
      function toggleDropdown() {
        var dropdown = document.getElementById("dropdownMenu");
        if (dropdown.style.display === "block") {
          dropdown.style.display = "none";
        } else {
          dropdown.style.display = "block";
        }
      }
    </script>

    Explanation:

    • JavaScript FunctiontoggleDropdown() toggles the display of the dropdown menu between block (visible) and none (hidden).
    • Onclick Event: The dropdown opens when the user clicks on the “Services” link.

    Summary

    Creating effective links and navigation systems is crucial for a smooth user experience on websites. The anchor (<a>) tag enables basic linking, and bookmarks help users navigate within a page. Navigation bars, styled with CSS, guide users through different sections of a website, and dropdown menus allow for hierarchical navigation. Combining these elements allows you to create professional, user-friendly web navigation that improves site usability and accessibility.

  • HTML Text Formatting

    HTML Formatting elements

    Text formatting is an essential part of creating web content, as it helps structure and emphasize important information on a webpage. HTML provides various tags to format text, including paragraphs, headings, bold or italic text, and quotations. In this guide, we’ll explore the most commonly used text formatting tags in HTML.

    Paragraphs ( < p >)

    The <p> tag is used to define paragraphs. It automatically adds spacing before and after the paragraph, helping to separate blocks of text.

    Example:

    <p>This is a paragraph of text. HTML makes it easy to create well-structured web content.</p>

    This tag is ideal for grouping sentences and creating readable blocks of content.

    Paragraphs ( < h1 > to < h6 >)

    Headings are used to define the structure of content, with <h1> being the highest level (used for main titles) and <h6> the lowest (used for smaller subheadings).

    Example:

    <h1>This is a Main Heading</h1>
    <h2>This is a Subheading</h2>
    <h3>This is a Sub-subheading</h3>
    • <h1>: Most important heading (used for page titles).
    • <h2>: Subheading (used for sections or major topics).
    • <h3> to <h6>: Used for further subdivisions within sections.

    Headings are essential for both visual structure and SEO, as search engines use headings to understand the hierarchy of content.

    Text Formatting Tags

    HTML offers various text formatting tags to emphasize or style content within a paragraph or other elements. Here’s a look at the most commonly used formatting tags:

    • Bold Text (<b> and <strong>)
      • <b>: Renders text in bold without adding semantic meaning.
      • <strong>: Renders text in bold and also implies strong importance.
      Example:
    <p>This is <b>bold text</b> without importance.</p>
    <p>This is <strong>important bold text</strong> with semantic meaning.</p>
    • Italic Text (<i> and <em>)
      • <i>: Renders text in italics but without extra emphasis.
      • <em>: Renders text in italics and also implies emphasis.
      Example:
    <p>This is <i>italic text</i> without emphasis.</p>
    <p>This is <em>emphasized italic text</em> with meaning.</p>
    • Underlined Text (<u>)The <u> tag underlines the text.Example:
    <p>This is <u>underlined text</u>.</p>
    • Small Text (<small>)The <small> tag renders text in a smaller size.Example:
    <p>This is <small>small text</small>.</p>
    • Marked Text (<mark>)The <mark> tag highlights text by adding a background color (usually yellow).Example:
    <p>This is <mark>highlighted text</mark>.</p>
    • Deleted and Inserted Text (<del> and <ins>)
      • <del>: Displays text with a strikethrough, indicating that it has been deleted.
      • <ins>: Displays text with an underline, indicating newly inserted text.
      Example:
    <p>This text was <del>deleted</del> but this text is <ins>inserted</ins>.</p>
    • Subscript and Superscript (<sub> and <sup>)
      • <sub>: Displays text in subscript (useful for chemical formulas, mathematical expressions).
      • <sup>: Displays text in superscript (useful for exponents, ordinal numbers).
      Example:
    <p>Water's chemical formula is H<sub>2</sub>O.</p>
    <p>E = mc<sup>2</sup> is Einstein's famous equation.</p>

    Quotations and Citations

    HTML provides special tags for quoting text and referencing external sources.

    • Blockquote (<blockquote>)The <blockquote> tag is used for long, block-level quotations. Typically, it indents the quoted text.Example:
    <blockquote>
      "The only limit to our realization of tomorrow is our doubts of today."
      — Franklin D. Roosevelt
    </blockquote>

    Blockquotes are useful for longer quotes that stand alone as a separate block of content.

    • Inline Quote (<q>)The <q> tag is used for shorter, inline quotes. It typically adds quotation marks around the text.Example:
    <p>He said, <q>The journey of a thousand miles begins with a single step.</q></p>
    • Citations (<cite>)The <cite> tag is used to reference the title of a work, such as a book, website, or research paper. The text is usually italicized.Example:
    <p>The book <cite>To Kill a Mockingbird</cite> is a classic of American literature.</p>

    Summary

    Text formatting in HTML allows you to structure and emphasize content using a variety of tags. Paragraphs (<p>) and headings (<h1> to <h6>) organize the document into readable sections, while formatting tags like <b><i><u>, and <strong> help add emphasis to specific parts of the text. Quotation tags like <blockquote> and <q> make it easy to include quotes, while <cite> provides a way to properly cite sources. These tools are essential for creating well-structured and visually appealing web pages that are also accessible and meaningful for users and search engines.