HTML Elements
Understand the building blocks of HTML documents
Introduction to HTML Elements
What is a Tag?
A tag is a keyword enclosed in angle brackets that defines the start and end of an HTML element. Tags are used to create elements and apply formatting or structure to the content.
<tagname>
What is an HTML Element?
Elements define the structure and content of web pages, such as headings, paragraphs, links, images, and more.
HTML elements are the fundamental components of an HTML document. They consist of a start tag, content, and an end tag.
An element consists of:
- Start Tag: Indicates the beginning of an element, e.g.,
<tagname> - Content: The text or other elements contained within the element
- End Tag: Indicates the end of an element, e.g.,
</tagname> <h1></h1> to <h6></h6>- Headings<p></p>- Paragraph<a></a>- Anchor (link)<img>- Image<div></div>- Division or section<span></span>- Inline container
Example of an HTML Element:
<p>This is a paragraph.</p>
<h1>This is a heading</h1>
Self-Closing Elements:
Some HTML elements do not have content and are self-closing, meaning they do not require an end tag. These elements are written with a slash before the closing angle bracket.
<img src="image.jpg" alt="Description" />
<br />
<hr />