Mastering the Top 20 HTML Tags for web developers

Tajammal Maqbool
8 min readSep 25, 2023

--

HTML and HTML Tags

HTML

HTML stands for “HyperText Markup Language”. It is the standard markup language used to create and structure content on the World Wide Web. HTML uses a system of tags and attributes to define the various elements and components of a web page, such as text, images, links, headings, paragraphs, forms, and more.

HTML documents are plain text files with a .html file extension, and they are interpreted by web browsers to display web content to users. The structure of an HTML document typically includes a series of nested elements that define the content's layout and hierarchy.

HTML Tags

HTML Tags

HTML tags are the fundamental building blocks of HTML (HyperText Markup Language) documents. They are used to structure and format content on webpages, defining the various elements and components that make up a webpage. HTML tags consist of keywords enclosed in angle brackets (“<” and “>”) and are typically used in pairs: an opening tag and a closing tag.

Top 20 Tags of HTML

html

The <html> element is the root element of an HTML document. It contains all the other elements on the page and serves as the outermost container for the entire webpage. Every HTML document must start with an <html> element.

<!DOCTYPE html>

<html>
<head>
.....
</head>
<body>
.....
</body>
</html>

head

The <head> element is a crucial part of the HTML document that is not visible to users when they view a webpage. Instead, it contains essential information for browsers and search engines to interpret and display the page correctly.

<head>
<meta charset="UTF-8">
<title>My Webpage</title>
<meta name="description" content="Welcome to My Webpage, where you can explore our services and products.">
<link rel="stylesheet" href="styles.css">
</head>

title

The <title> tag, located within the <head> section of an HTML document, plays a pivotal role in defining the webpage's title, which is displayed on the browser's title bar or tab. This tag is not visible on the actual webpage but serves a critical purpose in user experience and search engine optimization.

<head>
<title>My Awesome Website</title>
</head>

meta

The <meta> tag in HTML is a versatile element primarily used to provide metadata about a webpage. This metadata doesn't appear directly on the page but serves critical functions for search engines, browsers, and web crawlers. One of the most common uses is specifying the character encoding of the document, ensuring that special characters and symbols display correctly.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="A brief description of the webpage's content.">
<meta name="keywords" content="HTML, CSS, web development">
<meta name="author" content="John Doe">
<meta http-equiv="refresh" content="60">
<meta name="robots" content="index, follow">
</head>
<body>
.....
</body>
</html>

link

The <link> tag in HTML is a crucial element used to establish relationships between the current document and external resources. Typically placed within the <head> section of an HTML document, it is primarily employed for linking stylesheets, icons, and other resources essential for the webpage's functionality and aesthetics. For instance, you can use the <link> tag to connect an external CSS file to your HTML document, ensuring that the styles defined in the CSS file are applied to the webpage.

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>My Webpage</title>
<link rel="stylesheet" type="text/css" href="styles.css">
<link rel="icon" type="image/png" href="favicon.png">
</head>
<body>
.....
</body>
</html>

style

The <style> tag is a fundamental HTML element used to embed CSS (Cascading Style Sheets) directly within an HTML document. It allows web developers to define the visual styling and presentation of elements on a webpage. By including CSS rules within the <style> tag, you can control aspects such as fonts, colors, spacing, layout, and more. This inline CSS takes precedence over external stylesheets, giving you the flexibility to apply specific styles to a single page or even a single element.

<!DOCTYPE html>
<html>
<head>
<title>Inline CSS Example</title>
<style>
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
}
h1 {
color: #3366cc;
}
</style>
</head>
<body>
<h1>Welcome to My Website</h1>
<p>This is a sample webpage with inline CSS styles applied.</p>
</body>
</html>

script

The <script> tag is a fundamental HTML element used for embedding JavaScript code within an HTML document. It plays a critical role in enhancing the interactivity and functionality of webpages. You typically place the <script> tag within the <head> or at the end of the <body> section of an HTML document.

<!DOCTYPE html>
<html>
<head>
<title>JavaScript Example</title>
<script>
function greet() {
alert('Hello, World!');
}
</script>
</head>
<body>
<button onclick="greet()">Click me</button>
</body>
</html>

body

The <body> tag is a fundamental element in HTML that encapsulates the visible content of a webpage. It represents the main content area where text, images, links, and other media are displayed to users. Everything users see and interact with on a webpage is typically contained within the <body> tag.

<!DOCTYPE html>
<html>
<head>
<title>My Webpage</title>
</head>
<body>
<h1>Welcome to My Webpage</h1>
<p>This is a sample paragraph of text.</p>
<img src="image.jpg" alt="A beautiful image">
<a href="https://www.example.com">Visit Example.com</a>
</body>
</html>

h1 — h6

The <h1> to <h6> tags in HTML represent headings of varying levels of importance, forming a hierarchical structure for your content. <h1> is the highest level, typically used for the main page title, while <h6> is the lowest.

<h1>Breaking News</h1>
<h2>Important Developments</h2>
<p>Today, groundbreaking discoveries...</p>
<h2>Local Impact</h2>
<p>In our city, this news means...</p>
<h3>Community Reactions</h3>
<p>Residents shared their thoughts...</p>
<h4>Expert Insights</h4>
<p>Renowned experts weighed in...</p>

p

The <p> tag, short for "paragraph," is a fundamental HTML element used to structure and display text content within a webpage. It is a block-level element, which means it creates a distinct paragraph that starts on a new line and is separated from the content above and below it.

<p>This is a sample paragraph. It can contain text, 
images, links, and other inline elements to convey
information and provide context to the webpage's content.
Paragraphs are often used to break down long text into
smaller, more manageable chunks, improving readability
and user comprehension.</p>

a

The <a> tag in HTML is used to create hyperlinks, which are essential for connecting webpages and navigating the internet. This tag defines an anchor point, specifying the destination URL that users can access by clicking the linked text or element. For instance, if you want to link to a different webpage, you enclose the text or image you want to act as a link within <a> tags and set the href attribute to the URL of the target page.

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

img

The <img> tag in HTML is used to embed images within a webpage. It's an essential element for adding visual content, such as photos, illustrations, and icons, to your site.

<img src="image.jpg" alt="Description of the image">

video

The <video> tag is a fundamental HTML element that enables the seamless embedding of video content directly into webpages without the need for external plugins. This tag serves as a container for video files, facilitating both playback and control through HTML attributes and JavaScript scripting.

<video src="example.mp4" controls></video>

ol — ul

The <ol> tag in HTML is used to create ordered lists, where each list item is automatically numbered or lettered sequentially. This tag is particularly useful when you want to present information in a structured and ordered manner.

The <ul> tag, short for "unordered list," is a fundamental HTML element used to create lists of items that do not have a particular order or sequence. It typically contains one or more <li> (list item) elements, which represent individual items within the list.

<ol>
<li>Preheat the oven to 350°F (175°C).</li>
<li>Grease a baking pan with butter or cooking spray.</li>
<li>In a mixing bowl, combine the dry ingredients.</li>
<li>In another bowl, beat the eggs and add the wet ingredients.</li>
<li>Gradually mix the wet and dry ingredients together.</li>
<li>Pour the batter into the prepared baking pan.</li>
<li>Bake for 30-35 minutes or until a toothpick comes out clean.</li>
<li>Let the cake cool before serving.</li>
</ol>
<ul>
<li>1 cup of flour</li>
<li>1/2 cup of sugar</li>
<li>2 eggs</li>
<li>1 teaspoon of vanilla extract</li>
</ul>

div

The <div> tag, short for "division," is a fundamental HTML element used for grouping and structuring content within a web page. It serves as a container that allows you to apply styles, scripts, or other attributes to a specific section of content. This tag is particularly useful when you want to create distinct sections or layout components on a webpage, such as headers, footers, sidebars, or content blocks.

<div id="header">
<h1>Welcome to My Website</h1>
</div>
<div id="content">
<p>This is the main content of my webpage.</p>
</div>
<div id="footer">
<p>&copy; 2023 My Website</p>
</div>

span

The <span> tag is an inline container element in HTML that is often used for applying styles or scripting to a specific portion of text within a larger block of content. It doesn't create a new line or any visible structure on its own but can be a powerful tool for targeting and manipulating text or inline elements within a paragraph or other text-based content.

<p>This is a <span style="font-weight: bold; color: red;">highlighted</span> word.</p>

table

The <table> tag in HTML is a powerful element used for creating structured data displays on webpages. Tables are essential for organizing information, such as charts, grids, and lists, in a clear and orderly fashion. When you open a <table> tag, you typically follow it with a pair of nested tags: <tr> (table row) to define rows and <td> (table data) to define individual cells within those rows.

<table>
<tr>
<td>Product</td>
<td>Price</td>
</tr>
<tr>
<td>Laptop</td>
<td>$800</td>
</tr>
<tr>
<td>Smartphone</td>
<td>$400</td>
</tr>
</table>

form

The <form> tag is a fundamental HTML element used to create interactive web forms, allowing users to input data that can be submitted to a server for processing. This tag acts as a container for various input elements such as text fields, checkboxes, radio buttons, and buttons. When a user fills out a form and clicks a submit button, the data is sent to a specified server for processing, often resulting in actions like user registration, search queries, or data submission.

<form action="login.php" method="post">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<br>
<input type="submit" value="Login">
</form>

input

The <input> tag is a fundamental HTML element used for creating user input fields on web forms. It serves as a versatile tool for gathering various types of information from website visitors. To use it, you define the input's type attribute to specify the kind of input you want, such as text, email, password, or radio buttons.

<input type="email" id="userEmail" name="email" placeholder="Enter your email address">

canvas

The <canvas> tag in HTML is a versatile element that provides a blank drawing area on a web page, allowing for dynamic rendering of graphics, animations, and interactive visual content using JavaScript. This tag acts as a container for graphics, which can be manipulated programmatically to create various shapes, charts, animations, and even complex games.

<canvas id="myCanvas" width="200" height="100"></canvas>
<script>
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
ctx.fillStyle = 'blue';
ctx.fillRect(10, 10, 150, 80);
</script>

Conlusion

With these fundamental HTML tags in your toolkit, you’ll have a solid foundation to begin your web development journey. Each tag serves a specific purpose and, when used in combination, allows you to create engaging and dynamic web experiences. In this article, we’ll explore each of these tags in detail, providing examples and best practices to help you become a proficient web developer. Happy Coding!!

--

--

Tajammal Maqbool

I have been a Website & Game Developer since 2020. I graduated in Computer Science from UET Lahore. Passionate about sharing my programming knowledge!!!!