HTML Tags & Elements


An HTML tag represents a code segment which establishes both the beginning and ending points of an element within an HTML document. Tags are enclosed in angle brackets (<>).


What is an HTML Element?

An HTML element encompasses all content between the opening and closing tags.

html-tags-and-elements


Syntax of an HTML Element

<tagname>Content goes here</tagname>

Example

<!DOCTYPE html>
<html>
<head>
  <title>My First HTML Page</title>
</head>
<body>
  <h1>Hello, World!</h1>
  <p>This is a paragraph.</p>
</body>
</html> 
  • <p> is the start tag
  • </p> is the end tag
  • The entire line is a paragraph element

Types of HTML Elements

Paired (Container) Elements

These have opening and closing tags.

<h1>This is a heading</h1>
<p>This is a paragraph.</p>
<a href="#">This is a link</a>  

Empty (Void) Elements

These do not have closing tags and often have attributes

<br>  <!-- Line break -->
<hr>  <!-- Horizontal rule -->
<img src="logo.png" alt="Logo">
<input type="text">  

Commonly Used HTML Tags

Tag Description
<html> Root element of an HTML document
<head> Metadata, title, styles, etc.
<title> Title shown in browser tab
<body> Visible content
<h1>–<h6> Headings from large to small
<p> Paragraph
<a> Anchor (hyperlink)
<img> Image
<ul>, <ol> Unordered/Ordered list
<li> List item
<table>, <tr>, <td> Table components



OnlineTpoint is a website that is meant to offer basic knowledge, practice and learning materials. Though all the examples have been tested and verified, we cannot ensure the correctness or completeness of all the information on our website. All contents published on this website are subject to copyright and are owned by OnlineTpoint. By using this website, you agree that you have read and understood our Terms of Use, Cookie Policy and Privacy Policy.