What is tag in HTML?

Last updated 3 months, 3 weeks ago | 150 views 75     5

Tags:- HTML

HTML | Basic tags

A tag is a string in the language enclosed in angle brackets. An opening tag does not begin with a slash (/). An ending or closing tag is a string that begins with a slash (/). For example: <html> </html>, <body><body>, etc.

Each tag has there own work to define how web browsers format and display the content of the HTML documents.

 

HTML documents must start with a document type declaration: <!DOCTYPE html>.

A whole document in HTML begins with <html> and ends with </html>.

The visible part of the HTML document is between <body> and </body>.

<!DOCTYPE html>
<html>
<head>
<title>My Title</title>
</head>
<body>

<h1>My Heading</h1>
<p>My paragraph.</p>

</body>
</html>

The <!DOCTYPE> Declaration

This tag represents the language of an HTML document. In this case, the language is HTML 5.

It must only appear once, at the top of the page before the HTML tag.

The <!DOCTYPE> declaration is not case sensitive.

<!DOCTYPE html>

 


HTML head

The <head> tag contains all the metadata for the page, stuff mostly meant for search engines and other computer programs.

HTML title

The <title> tag is used to specify the page name and it appears at the top of the browser window or tab.

<head>
<title>My Title</title>
</head>

HTML Headings

HTML headings are defined with the <h1> to <h6> tags.

<h1> and <h2> defines the most important heading, while the remaining tags should be used for sub-headings and least important heading: 

<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>

HTML Paragraphs

HTML paragraphs are defined with the <p> tag. It provides a way to structure your text into different paragraphs.

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

HTML Line Break

The <br /> tag is used for a line break. this is an empty tag and does not have the closing tag.

The <br /> tag has a space between the characters "br" and the forward-slash. If you omit the space, old browsers will have trouble rendering the line break, if you miss the forward-slash character and just use <br> it is not valid in XHTML.

<p>This is a <br />line brake.</p>

HTML Links

HTML links are defined with the <a> tag.

a href="http://www.studyzone4u.com">This is a link</a>

Here "href" is an attribute that specifies the destination.

Attributes are used to provide additional information about HTML elements.


HTML Images

HTML images are defined with the <img> tag.

<img src="image.jpg" alt="Flawer image" width="100" height="120">

Here the source file (src), alternative text (alt), width, and height are provided as attributes.