HTML Block & Inline Elements 🎯

beginner
7 min

HTML Block & Inline Elements 🎯

Welcome to the HTML Block & Inline Elements tutorial! In this lesson, we'll explore the building blocks of HTML - blocks and inline elements. 🚀

What are HTML Elements? 📝

HTML elements are the basic building blocks of web pages. Each element represents a piece of a web page, such as a heading, paragraph, image, or link.

Block Elements 💡

Block elements are used to create sections and layout on a web page. These elements start on a new line and take up the full width available unless specified otherwise. Here are some common block elements:

  1. <h1> - Heading 1 (largest heading)
  2. <h2> - Heading 2
  3. <h3> - Heading 3
  4. <h4> - Heading 4
  5. <h5> - Heading 5
  6. <h6> - Heading 6 (smallest heading)
  7. <p> - Paragraph
  8. <div> - Division (used for grouping content)
  9. <ul> - Unordered list (list without numbers)
  10. <ol> - Ordered list (list with numbers)
  11. <li> - List item
  12. <a> - Anchor (link)
  13. <form> - Form (for user input)
  14. <button> - Button

Inline Elements 💡

Inline elements are used to add content within other block elements without starting on a new line. Here are some common inline elements:

  1. <span> - Used for grouping inline content
  2. <strong> - Bold text
  3. <em> - Emphasized text
  4. <img> - Image
  5. <a> - Link (can also be used as a block element)
  6. <input> - Form input

Example HTML Document 📝

Let's see a simple example of HTML document using some of the elements we've learned:

html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>HTML Block & Inline Elements Example</title> </head> <body> <h1>Welcome to CodeYourCraft! 🎉</h1> <p>In this tutorial, we'll learn about HTML Block & Inline Elements.</p> <h2>Block Elements</h2> <ul> <li><strong>h1</strong> - Heading 1</li> <li><strong>h2</strong> - Heading 2</li> <li><strong>p</strong> - Paragraph</li> <li><strong>div</strong> - Division</li> </ul> <h2>Inline Elements</h2> <p>Here are some common inline elements:</p> <p><strong>span</strong> - Used for grouping inline content</p> <p><em>em</em> - Emphasized text</p> <p><img src="image.jpg" alt="Image example" width="200" height="100"></p> <p><a href="https://www.codeyourcraft.com">Visit CodeYourCraft.com</a></p> </body> </html>

Quiz 🎯

Quick Quiz
Question 1 of 1

Which HTML element is used to create a heading on a web page?