0
0
HTMLmarkup~5 mins

What is an HTML element

Choose your learning style9 modes available
Introduction

An HTML element is a building block of a webpage. It tells the browser what content to show and how to organize it.

When you want to add a heading or paragraph to a webpage.
When you need to insert an image or a link.
When you want to create a list of items.
When you want to group content together for styling or layout.
When you want to add buttons or forms for user interaction.
Syntax
HTML
<tagname>content</tagname>
An element usually has an opening tag and a closing tag.
Some elements can be empty and self-close, like .
Examples
A paragraph element with text inside.
HTML
<p>This is a paragraph.</p>
An image element that is self-closing and shows a picture.
HTML
<img src="image.jpg" alt="A photo">
A heading element that shows big bold text.
HTML
<h1>Welcome!</h1>
Sample Program

This webpage shows a heading, a paragraph, and an image. Each is an HTML element.

HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>HTML Element Example</title>
</head>
<body>
  <h1>This is a heading</h1>
  <p>This is a paragraph explaining what an HTML element is.</p>
  <img src="https://via.placeholder.com/150" alt="Placeholder image">
</body>
</html>
OutputSuccess
Important Notes

Always close your elements properly to avoid display problems.

Use meaningful tags to help browsers and screen readers understand your content.

Summary

An HTML element is a tag that wraps content to tell the browser how to display it.

Elements usually have opening and closing tags, but some can self-close.

Elements build the structure and content of webpages.