HTML tags are essentially keywords that define how the content on a web page should be formatted and displayed. Tags are a type of keyword that tells us how to format and display content.
With the help of a web browser, we can distinguish between HTML content and simple content. HTML tags have three main parts:
- Opening tag
- Closing tag
- Content
However, many HTML tags are unclosed. When a web browser reads an HTML document, it reads from top to bottom and left to right. HTML tags are used to read HTML documents. HTML tags have different properties.
An HTML file should have essential tags so that the web browser can distinguish between HTML text and simple text. You can use as many tags as you need.
Each tag performs a task. We write HTML tags in the following way:
- All tags should be enclosed in these brackets <>.
- If you use an opening tag, you must also use a closing tag.
HTML Meta Tags
<!DOCTYPE>
= used for opening.<title>
= to present the title on the status bar.
HTML Text Tags
<p>
= indicates a paragraph tag.<h1>
= represents heading 1 tag.<h2>
= represents heading 2 tag.<h3>
= represents heading 3 tag.<h4>
= represents heading 4 tag.<h5>
= represents heading 5 tag.<h6>
= represents heading 6 tag.<strong>
= represents bold text.<address>
= represents the author’s information.<em>
= indicates emphasis.<abbr>
= abbreviation.<acronym>
= indicates an acronym for words.<bdo>
= represents bi-directional override.<blockquote>
= represents content from another source.<cite>
= represents a title, book, website, etc.<code>
= represents a part of programming code.<del>
= represents deleted text.<dfn>
= represents a definition term.<kbd>
= represents keyboard input.<pre>
= represents preformatted text.<samp>
= represents sample output.<var>
= represents a variable name.<br>
= used to apply a single line break.<a>
= to provide a link.
HTML Link Tags
<a>
= represents an anchor.<base>
= defines the base URL.
HTML Image and Object Tags
<img>
= used to insert an image.<area>
= defines an area of the image map.<map>
= defines an image map.<param>
= defines parameters for an object.<object>
= used to embed an object.
HTML List Tags
<ul>
= defines an unordered list.<ol>
= defines an ordered list of items.<li>
= represents items in a list.<dl>
= defines a description list.<dt>
= defines a term in a description list.<dd>
= provides a definition.
HTML Table Tags
<table>
= represents data in a tabular form.<tr>
= defines a row.<td>
= defines a cell.<th>
= defines a header cell.<tbody>
= represents the body content.<font>
= defines font size, color, and face.<col>
= defines a column.<colgroup>
= defines a group of columns.<caption>
= defines a caption for a table.
HTML Form Tags
<input>
= defines an input control.<textarea>
= defines a multi-line input control.<select>
= represents a control to provide a menu of options.<option>
= defines an option in a select list.<optgroup>
= groups options in a select list.<button>
= represents a clickable button.<label>
= defines a text label.<legend>
= defines a caption for a fieldset.
HTML Scripting & Code Tags
<script>
= used to add or include JavaScript in an HTML file.<code>
= used to display code.<link>
= used to link CSS files.
HTML Tags Example
File: html_tags.html
HTML Tags Examples
An HTML language is used to create web pages.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>HTML Tags Examples</title>
</head>
<body>
<!-- abbr tag -->
<p>An <abbr title="Hypertext Markup Language">HTML</abbr> language is used to create web pages. </p>
<!-- mark tag -->
<p>This tag will <mark>highlight</mark> the text.</p>
<!-- strong tag -->
<p>In HTML it is recommended to use <strong>lower-case</strong>, while writing code. </p>
<!-- em tag -->
<p>HTML is an <em>easy</em> to learn language.</p>
<!-- dfn tag -->
<p><dfn>HTML</dfn> is a markup language. </p>
<!-- blockquote -->
<blockquote><p>"The first step toward success is taken when you refuse to be a captive of the environment in which you first find yourself."</p></blockquote>
<cite>-Mark Caine</cite>
<p>Steve Jobs said: <q>If you are working on something that you really care about, you don’t have to be pushed. The vision pulls you.</q></p>
<!-- code tag -->
<p>First JavaScript program</p>
<p>
<code>
<script type="text/javascript">
console.log('Hello JS');
</script>
</code>
</p>
<!-- keyboard tag -->
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy.</p>
<!-- address tag -->
<address>You can ask your queries by contacting us on <a href="/page/contact-us">Contact Us</a>.
<br> You can also visit at: <br>Your address.
</address>
</body>
</html>
This HTML example demonstrates the usage of various HTML tags, each serving a specific purpose in structuring and formatting the content of the web page.